0.2.3 • Published 6 years ago

mongo-plus v0.2.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
6 years ago

Mongo+ (mongo-plus)

The promise based easy-to-use MongoDB module

Installing Mongo+ For Use

To install mongo+ run the following command: npm install --save mongo-plus

Usage Of The Module

const Mongo = require("mongo-plus");
const Database = require("connection_url", "database"); // replace connection_url with the url you are connecting to, database to what database you want to access

Database.Connect().then(() => { // Connect to the database and wait for success
	Database.Create("random").then(col => console.log(col)); // create a collection
	Database.Drop("random"); // drop/delete a collection
	Database.Insert({ name: "hi" }, "random").then(doc => console.log(doc)); // insert a document
	Database.Remove({ name: "hi"}, [[name, "hi"]], "random"); // equivelent to db.collection.findOneAndRemove()
	Database.Update({ name: "hi" }, { aids: yes }, "random").then(() => {}); // update a document in a collection
	Database.Get({ name: "hi" }, "random").then(res => console.log(res)); // fetch a document from a collection
});