Coder Social home page Coder Social logo

mongodb-promise's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mongodb-promise's Issues

Error message in connection

I have a project in the cloud9 cloud service with the following code:

var url = "mongodb://localhost:27017/learnyoumongo";
var mongo = require('mongodb-promise').MongoClient;
mongo.connect(url).then((db)=> db.close());

Running the code with node.js engine I get the following error:

{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version

I am using the node.js v4.4.5 and mongodb-promise v0.0.4

update inside each resolves even update has not finsihed

I need to fetch all records from a collection "people" that matches specific criteria and then update each of them.

For that I have this code to find all people:

`return db.collection('people')

.then( (collection) => {
// Store reference to collection for future use
peopleCollection = collection;

return collection.find({a:1})

})`

An then invoke this to update each record:

`.then( (people) => {

// Process each people
return people.each( (person) => {

    person.b = 2;

    // Where peopleCollection is a reference to my collection
    return peopleCollection.update({_id: person._id}, person)
})

})`
I then add another promise chain to fetch all people where b != 2 and I find many records and I counted them. But when I execute this script repeatedly, the count decreases which means mongo is still updating other records when the promise has already resolved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.