docci-db
v0.0.8
Published
A document based Node.js DB
Downloads
1
Readme
Very fast, simplistic NoSQL database. Build and ready for your Node.js application.
Installation
Use the package manager NPM to install DocciDB.
npm install docci-db
Setting up model schemes
In your project root you will need to create a folder ./models/. In this folder you will place all of your collections & schemes. For validations DocciDB uses Validate.js. Here is an example of how:
/models/books.js
const books = {
"name": {
presence: true,
type:'string'
},
"pages": {
presence: true,
type: "number"
},
}
module.exports = books;
Communcating
To fetch, delete and update docuements in your DocciDB you can call the following functions.
getAll() - Fetching all the doucuments
const fetchAllBooks = await db.books.getAll();
get() - Fetches one document
const fetchAllBooks = await db.books.get(_id);
create() - Creates on document
const createdBook = await db.books.create({"name":"Hunger Games", "pages":516});
update() - Updates one document
const updatedBook = await db.books.update({"_id":"ceda09d7-fa2c-4058-a020-911f82af2a1b","name":"Hunger Games", "pages":516});
delete() - Deletes on document
const deletedBook = await db.books.delete(_id);
clear() - Deletes all of the documents in a collection
await db.books.clear();
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.