A MongoDb/IndexedDB like wrapper around Sqlite
You can not 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 2 years ago
src Added first few test cases 2 years ago
tests Added first few test cases 2 years ago
.gitignore Initial commit 2 years ago
README.md Initial commit 2 years ago
composer.json Initial commit 2 years ago
phpunit.xml Added phpunit manifest 2 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');