Skip to content

mattbit/flat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flat

Build Status Code Coverage Scrutinizer Code Quality

Flat is a flat-file database with a mongo-like API, written in PHP.

⚠️ Still under heavy development!

Inserting documents

$db = Flat::localDatabase("/path/to/db");

$doc = new Document([
    'title' => 'Flat',
    'description' => 'A flat NoSQL database',
]);

$db->collection('pages')->insert($doc);

Finding documents

$db->collection('pages')->find(['published' => true]);

// Something slightly more complex
$db->collection('pages')->find([
    'published' => true,
    'view_count' => [ '$gt' => 1000 ],
    'author' => ['$in' => [ 'john', 'jane', 'jack']]
]);

// Or with boolean combination
$db->collection('pages')->find([
    '$or' => [
        ['published' => false],
        ['author' => 'admin']
    ]
]);
Supported query operators

Logical: $and, $or, $not.

Comparison: $eq, $gt, $gte, $lt, $lte, $ne, $regex.

Array: $in, $nin.

Removing documents

$db->collection('pages')->remove(['published' => false]);

About

A flat file database for PHP

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages