A MongoDb/IndexedDB like wrapper around Sqlite
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Noccy e560ec4a4f Added phpunit manifest 3 years ago
src Added first few test cases 3 years ago
tests Added first few test cases 3 years ago
.gitignore Initial commit 3 years ago
README.md Initial commit 3 years ago
composer.json Initial commit 3 years ago
phpunit.xml Added phpunit manifest 3 years ago

README.md

LiteDB: An IndexedDB/MongoDb-inspired wrapper around SQLite

Usage

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.

$db->createStore("foo")
    ->addIndex("bar");

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.

Example

$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 ]);
    }
});


$db->users->add([
    'username' => 'bob',
    'password' => 'supersecret'
]);

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