PseudoDB
Lite & fast DB simulator for testing.
var pdb = ;
Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js.
If this is a brand new project, make sure to create a package.json
first with
the npm init
command.
Installation is done using the
npm install
command:
$ npm install pseudodb
Features
- Makes code testing easier
- Mimics Firestore
- Now supports graphDB properties
Functions
To create a new DB:
pdb;
To add a new document with a random id:
var id = pdb; //Returns the randomly created id
To create a new document with a specific id or to modify an exisitng document
pdb;
To change a particular field of a document
pdb;
To get details of a particular document
var result = pdb;
To get details of a particular db
var result = pdb;
To find a particular document in a db
var id = pdb; // FInds the first occuring match and returns the id
To find documents matching a criteria in a db
var id = pdb; // Finds all occuring matches and returns an array of ids
To add a relation to a doc with another doc
pdb; // Sets relation from doc with id a to doc with id b
To add a relation group to a doc with another doc
pdb; // Adds a relation from a to b in the relation group
To get a relation of a doc
console; // Logs the relation of the doc
To delete a doc
pdb;
To delete a db
pdb;
To Monitor Changes in a db
;
Example Code
const pdb = ; pdb; //Create a db with name test pdb; /*Add a new document with a random id.Take a look at the new file named test to see the added document*/ pdb; //Creates a doc with the id 'a' and stores the object pdb; //Changes the document with the id a pdb; //Changes the field name of the document with id a pdb; //Adds a new field Developer pdb; // Sets brother relation from doc with id a to doc with id b console; // Logs the content of the doc with id a to the console console; // Logs the content of the db to the console console; //Since the getdoc function returns an object, you can access the fields this way console; //Logs the id of the document which has the field 'name' as 'Alwin' console; //Logs an array of ids of all docs which has age as 20 ; // Monitors the db and Logs current and previous content of the db when db is changed console; // Logs the brother relation of the doc a pdb; // Deletes the doc with id a pdb; //Deletes the db