node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



A thin mongo wrapper which exposes mongodb as continuables


For now you can pass either a callback to each collection method or not pass in a callback and the function returns a continuable

var mongo = require("continuable-mongo")
var client = mongo("mongodb://localhost:27017/my_db")
var myCollection = client.collection("my-collection")
    some: "key",
    value: "pair"
}], function (err, inserted) {
    // inserted records 
        some: "key"
    }, function (err, result) {
        // result.value === "pair" 
        console.log("result", result)

Differences from mongodb/Collection


a collection object returned by client.collection has an additional .findById(id) method. This is used to find a record by it's mongodb _id. It's assumed that id is a string or otherwise valid argument to ObjectID and that the _id field on the mongodb record is a ObjectID

The purpose of this method is not have to manually require ObjectID to avoid littering your code base to mongodb internal references.

If you do need access to the raw ObjectID function there is a safer variant that can be required "continuable-mongo/object-id" which either returns a mongodb/ObjectID instance or will return an Error. Which means it's a function which will not throw but does need checking on the returned value.


npm install continuable-mongo


  • Raynos

MIT Licenced