2017 © Pedro Peláez
 

library mongo-lite

Schemaless database on top of SqLite

image

aheinze/mongo-lite

Schemaless database on top of SqLite

  • Friday, August 11, 2017
  • by aheinze
  • Repository
  • 6 Watchers
  • 121 Stars
  • 35 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 5 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

MongoLite

Schemaless database on top of SqLite, (*1)

Sample Usage

``` php $client = new MongoLite\Client(PATH_TO_WRITABLE_FOLDER); $database = $client->testdb; $collection = $database->products;, (*2)

$entry = ["name"=>"Super cool Product", "price"=>20];, (*3)

$collection->insert($entry);, (*4)

$products = $collection->find(); // Get Cursor, (*5)

if ($products->count()) {, (*6)

foreach($products->sort(["price"=>1])->limit(5) as $product) {
    var_dump($product);
}

}, (*7)


### Query collection In general you can use a callback or simple array as criteria ``` php $collection->find(function($document) { // recommended to query data return $document["price"] > 10; }); //or $collection->find(["price"=>['$gt'=>10]]); // only very simple criteria is supported (can be slow) //or just one $collection->findOne(function($document) { ... }); $collection->findOne([...]);

Writing documents

``` php $collection->insert($document); $collection->save($document); $collection->update($criteria, $data);, (*8)


### Delete documents ``` php $collection->remove($criteria);

API

Client, (*9)

``` php Client::listDBs() Client::selectDB(databasename) Client::selectCollection(databasename, collectionname), (*10)


**Database** ``` php Database::vacuum() Database::drop() Database::createCollection(collectionname) Database::dropCollection(collectionname) Database::getCollectionNames() Database::listCollections() Database::selectCollection(collectionname)

Collection, (*11)

``` php Collection::drop() Collection::renameCollection(newname) Collection::insert(document) Collection::save(document) Collection::update(criteria, data) Collection::remove(criteria) Collection::count() Collection::find(criteria) Collection::findOne(criteria), (*12)


**Cursor** ``` php Cursor::count() Cursor::limit(number) Cursor::skip(number) Cursor::sort(array) Cursor::each($callable) Cursor::toArray()

Installation

To install and use MongoLite via the composer PHP package manager just take these steps:, (*13)

If you don’t already have one, create the file composer.json in the root of your new project that is going to use MongoLite., (*14)

Add the following to the composer.json file.., (*15)

{
    "require": {
        "agentejo/mongo-lite": "dev-master"
    }
}

Install composer (if it isn’t already installed):, (*16)

curl -s https://getcomposer.org/installer | php
php composer.phar install

The Versions

11/08 2017

dev-master

9999999-dev https://github.com/aheinze/MongoLite

Schemaless database on top of SqLite

  Sources   Download

MIT

The Requires

  • php >=5.4.2

 

The Development Requires

database pdo sqlite no-sql schemaless

28/08 2015

1.0.0

1.0.0.0 https://github.com/aheinze/MongoLite

Schemaless database on top of SqLite

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

database pdo sqlite no-sql schemaless