0.0.2 • Published 10 years ago

mongopromise v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Mongopromise

Wrap over Mongoskin for easy access to databases and collections.

Methods

  • insert
  • update
  • find
  • findOne
  • remove

Full list of opportunities

Example

var db = new Database('test');

db.collection('mycollection')
    .insert({ a: 1 })
    .then(function(res) {
        return res.collection.update({ a: 1 }, { a: 1, ololo: 1 });
    })
    .then(function(res) {
        return res.collection.insert({ a: 2 });
    })
    .then(function(res) {
        return res.collection.update({ a: 2 }, { a: 2, ololo: 2 });
    })
    .then(function(res) {
        return res.collection.insert({ a: 3 });
    })
    .then(function(res) {
        return res.collection.find({ a: 2 });
    })
    .then(function(res) {
        console.log({ find: res.data });
        return res.collection.findOne({ a: 3 });
    })
    .then(function(res) {
        console.log({ findOne: res.data });
    })
    .fail(function(err) {
        console.log( err );
    })
    .done();

.then()

Link of the chain of asynchronous method calls collections.

...
.then(function(res) {
    return res.ctx.< method >(params);
})
...
  • res – response from previous operation:
    • ctx – context of collection
    • data – result of executing a getter-methods
  • method – method of collection to be executed asynchronously after the previous one in the chain
  • params – parameters for the method

License

MIT

0.0.2

10 years ago

0.0.1

10 years ago