Flat is a flat-file database with a mongo-like API, written in PHP.
$db = Flat::localDatabase("/path/to/db");
$doc = new Document([
'title' => 'Flat',
'description' => 'A flat NoSQL database',
]);
$db->collection('pages')->insert($doc);$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']
]
]);Logical: $and, $or, $not.
Comparison: $eq, $gt, $gte, $lt, $lte, $ne, $regex.
Array: $in, $nin.
$db->collection('pages')->remove(['published' => false]);