A MongoDb/IndexedDB like wrapper around Sqlite
Go to file
2020-07-13 23:25:14 +02:00
src Added first few test cases 2020-07-13 23:24:30 +02:00
tests Added first few test cases 2020-07-13 23:24:30 +02:00
.gitignore Initial commit 2020-06-27 01:00:32 +02:00
composer.json Initial commit 2020-06-27 01:00:32 +02:00
phpunit.xml Added phpunit manifest 2020-07-13 23:25:14 +02:00
README.md Initial commit 2020-06-27 01:00:32 +02:00

LiteDB: An IndexedDB/MongoDb-inspired wrapper around SQLite


To use LiteDb, pass the path to the database file, the current schema version and an upgrade handler. This makes it easy to upgrade the database as new stores and indexes are needed.

Create (or upgrade) a store

Use the createStore() method to create or upgrade a store. If the store exists, the instance will be returned so the same fluid code style can be used.


Create (insert) data

Create records using the add() or addAll() methods on the store.

Update data

Update records using the put() method on the store.

Delete data

Delete records using the delete() method on the store.

Retrieving (selecting) data

Find records with the get() method, passing the key value to match against and optionally the key to match.


$db = new LiteDb("data.db", 1, function ($db, $oldVersion) {
    switch ($oldVersion) {
        case null:
            $db->createStore('users', 'username')
                ->addIndex('username', [ 'unique' => true ])
                ->addIndex('id', [ 'autoIncrement' => true ]);

    'username' => 'bob',
    'password' => 'supersecret'

$user = $db->users->get('bob');