
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
jsondbfs-mongo
Advanced tools
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.
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.
//SUPPORT ASYNC/AWAIT or Callback
var JSONDBFSDriver = require('jsondbfs-mongo');
var database;
// receives an array containing the collections you want to create / use ['Users', 'Others']
// existing collections will be attached
JSONDBFSDriver.connect(['Users'], {path: '/path/to/store/collections', driver: 'memory'}, function(err, db){
database = db;
});
// now the collection can be accessed in the database object: 'database['Users'].insert' or 'database.Users.insert'
database.Users.insert({name: 'Manuel', roles: ['Admin', 'Super']}, function(err, document){
// inserts the document and returns it representation in the database (including the internal id)
...
});
database.Users.count(function(err, count){
// returns the length of the collection
...
});
database.Users.count({name: 'Manuel'}, function(err, count){
// returns the number of documents matching that criteria
...
});
database.Users.update({name: 'Manuel'}, {name: 'Manuel Martins', token: 'xsf32S123ss'}, function(err, result){
// updates a specified document based on a criteria
// result is { nMatched: 1, nModified: 1, nUpserted: 0 }
...
});
database.Users.findAndModify({name: 'Manuel Martins'}, {name: 'Manuel Martins', token: 'f32S123'}, {retObj: true}, function(err, result){
// updates a specified document based on a criteria
// result is the updated document
// withou retObj info on updated / insert { nMatched: 1, nModified: 1, nUpserted: 0 } is returned
...
});
database.Users.find(function(err, documents){
// returns everything since there is no criteria specified
...
});
database.Users.find({name: 'John'},function(err, documents){
// returns an array with the elements that match the criteria
...
});
database.Users.findOne({name: 'John'},function(err, document){
// returns the first document that matches the criteria
...
});
database.Users.remove({name: 'Manuel'}, function(err, success){
// returns true if records were removed
...
});
await database.Users.updateOne({name: 'Manual'},{age: 30})
... updateMany, deleteOne, deleteMany same mongoose (MONGODB)
Support for Query and Projection Operators:
database.Users.findOne({
identities: {
$elemMatch: {
id: identity.id,
provider: identity.provider
}
}
}, function (err, document) {
// returns the first document that matches the criteria inside an array of identities
...
});
database.Collection.find({
quantity: { $gt: 25 }
}, function (err, documents) {
// returns the documents that matches the criteria
...
});
...
Support provided using json-criteria.
// Driver options
var JSONDBFSDriver = require('jsondbfs-mongo');
var database;
// driver options
var driverOptions = {
path: '/path/to/store/collections',
driver: 'memory',
memory: {
flush: true,
flushInterval: 10000
}
};
JSONDBFSDriver.connect(['Collection'], driverOptions, callback);
...
// Collection options
database.Collection.update(criteria, updateCriteria, {upsert: false, multi: true, retObj: true}, callback);
database.Collection.findAndModify(criteria, updateCriteria, {upsert: false, multi: true, retObj: true}, callback);
database.Collection.find(criteria, {multi: false}, callback);
database.Collection.remove(criteria, {multi: false}, callback);
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 if driver is 'memory'. Defaults to 'false'.
options.memory.flushInterval - Time interval to flush memory to disk. Only used if driver is 'memory'. Defaults to '10000'ms. (10s)
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 if they match. Accepts a boolean 'true' or 'false'. Defaults to 'true'.
options.retObj - Set to true if you want to return the updated object, otherwise a stats object is returned with info on updated records (as with MongoDB).
When removing or finding you can pass 1 option:
options.multi - Should update multiple records if they match. Accepts a boolean 'true' or 'false'. Defaults to 'true'.
Apache License, Version 2.0
FAQs
JSON Filesystem Database.
The npm package jsondbfs-mongo receives a total of 0 weekly downloads. As such, jsondbfs-mongo popularity was classified as not popular.
We found that jsondbfs-mongo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.