JSON DB FS
README
JSON FileSystem Database is a JSON Document database, such as MongoDB.
All methods are asynchronous and accessing / filtering is executed in parallel using async.
Currently supports 2 types of data drivers: Memory and Disk.
Memory driver is very performant. It is possible to flush data to disk (configurable).
Disk driver is less performant. Holds all data in disk, and reads/writes everytime you interact with the collection. Is implemented with Pessimistic Transaction Locking approach.
Based on Jalalhejazi, jsonfs.
Dependencies
Internal unique ids generated with node-uuid.
Object utilities with underscore.
Methods implemented using asynchronous and parallel strategies with async.
Pessimistic transaction locking is performed using lockfile.
Criteria queries on JSON objects Mongo style json-criteria.
API
var JSONDBFSDriver = ; var database; // receives an array containing the collections you want to create / use ['Users', 'Others'] // existing collections will be attached JSONDBFSDriver; // now the collection can be accessed in the database object: 'database['Users'].insert' or 'database.Users.insert' databaseUsers; databaseUsers; databaseUsers; databaseUsers; databaseUsers; databaseUsers; databaseUsers; databaseUsers; databaseUsers;
Support for Query and Projection Operators:
databaseUsers; databaseCollection; ...
Support provided using json-criteria.
Options
// Driver optionsvar JSONDBFSDriver = ;var database; // driver optionsvar driverOptions = path: '/path/to/store/collections' driver: 'memory' memory: flush: true flushInterval: 10000 ;JSONDBFSDriver;... // Collection optionsdatabaseCollection;databaseCollection;databaseCollection;databaseCollection;
Driver options
When initializing the Driver you can pass 4 options:
options.path - The path to store the db collection files. Defaults to '/tmp/'.options.driver - One of ['memory', 'disk'], defaults to 'disk'.options.memory.flush - If you want to flush the memory to disk. Only used
Collections options
When updating a record you can pass 3 options:
options.upsert - If record is not found and this options is set to true, a new record will be created. Accepts a boolean 'true' or 'false'. Defaults to 'false'.options.multi - Should update multiple records
When removing or finding you can pass 1 option:
options.multi - Should update multiple records
Please check the tests for more details.
License
Apache License, Version 2.0