mongo-simplified
v0.0.29
Published
mongo-simplified
Downloads
19
Readme
Mongo, Simplified
[in progress]
Install
npm install mongo-simplified
Init
var mongodb = require('mongo-simplified');
Connect using a string:
var mongo = new mongodb({
string: 'mongodb://127.0.0.1:27017/dbname'
});
mongo.init(function() {
console.log("Connected to MongoDB.");
});
Connect using an object:
var mongo = new mongodb({
host: "127.0.0.1",
port: 27017,
database: "dbname",
});
mongo.init(function() {
console.log("Connected to MongoDB.");
});
Connection Pool
var mongo = new mongodb({
string: 'mongodb://127.0.0.1:27017/dbname',
poolSize: 2
});
mongo.init(function() {
console.log("Connected to MongoDB.");
});
Queries
find
mongo.find({
collection: 'collection name',
query: {
id: {
$in: [1,2,3]
}
},
fields: {
_id: false, // Don't return the '_id'
id: true // return the 'id'
}
});