Questions tagged [node-mongodb-native]

The MongoDB Native Node.js driver is an officially supported driver providing a native asynchronous Node.js interface to MongoDB. It can be used on its own, but it also serves as the basis of several object mapping libraries, such as Mongoose.

The MongoDB Native Node.js driver is an officially supported driver written in pure JavaScript to provide a native asynchronous Node.js interface to MongoDB. The driver is optimized for simplicity. It can be used on its own, but it also serves as the basis of several object mapping libraries, such as Mongoose ODM.

Installing/upgrading

The easiest way to install the driver is to use npm:

$ npm install mongodb

Documentation

3.0 Driver

2.2 Driver

Related links

482 questions
3
votes
1 answer

MongoDB Bulk Update is slow

I'm running Mongo 2.6.3 I'm updating about 900 records, and sometimes up to 5000 records. I had this in a loop before, and for 900 records the upserts took about 1 minute to complete. Right now, I'm using the initializeUnorderedBulkOp API and it's…
Sean Clark
  • 1,436
  • 1
  • 17
  • 31
3
votes
5 answers

Mongoose: How to populate 2 level deep population without populating fields of first level? in mongodb

Here is my Mongoose Schema: var SchemaA = new Schema({ field1: String, ....... fieldB : { type: Schema.Types.ObjectId, ref: 'SchemaB' } }); var SchemaB = new Schema({ field1: String, ....... fieldC : { type: Schema.Types.ObjectId, ref:…
Mukund Kumar
  • 21,413
  • 18
  • 59
  • 79
3
votes
2 answers

MongoError when uploading a file using mongoose, gridfs-stream and multer

I am running express 4 using multer, gridfs-stream and mongoose with mongodb and I am attempting to upload a file and stream it to gridfs. The express route that does this is defined as: app.post('/uploadfile', function (req, res) { …
KennyE
  • 513
  • 6
  • 15
3
votes
1 answer

Filter documents by field value in array, Mongodb

Collection: [{ _id: 'Foo', plugs: [ { type: 'CE', code: 12 }, { type: 'SH': code: 34 } ] },{ _id: 'Bar', plugs: [ { type: 'T2', code: 23 }, { type: 'T2': code: 43 } ] }] In the plug array may…
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
3
votes
4 answers

How to check node-mongodb-native driver version?

I am using official node-mongodb-native driver in my project. Which was installed by doing npm install mongodb. However I want to check its version but not sure how to do so. There is nothing in the READ.ME file of that npm repo. Please…
Nikhil Yeole
  • 337
  • 5
  • 12
3
votes
3 answers

Limit find using Monk in mongoDB

I have a large collection of documents. I want to get the first 100 of these. From the Monk Docs, this is the find method I am using var documents = []; users.find({}, function (err, docs){ for(i=0;i<100;i++) …
Mayank
  • 124
  • 1
  • 8
3
votes
1 answer

How to handle error when MongoDB collection is updating in JavaScript(Node.js)

I've been trying get an error when running bad code. The following code tries to update a record which has _id value 5. There is actually no such record, but I can't catch any error messages with the following function. What should I…
efkan
  • 12,991
  • 6
  • 73
  • 106
3
votes
1 answer

Using extended JSON with node.js mongodb native driver

I've been looking at extened json http://docs.mongodb.org/manual/reference/mongodb-extended-json/ as I need my documents to survive a round trip from my web service to another service without loosing awareness of which data types were used on the…
jdrm
  • 621
  • 2
  • 8
  • 21
3
votes
1 answer

node-mongodb-native error when using geoNear

I've looked everywhere, and simply can't figure this out... I can get it to work in the mongo shell, but not in my application. Here's the code. I can get it to work here... (using the MongoDB shell) db.runCommand({geoNear: 'prints', near:…
joshula
  • 535
  • 1
  • 5
  • 19
3
votes
2 answers

MongoDB node native driver creating duplicate documents

I'm getting a duplicate document when using the mongodb-native-driver to save an update to a document. My first call to save() correctly creates the document and adds a _id with an ObjectID value. A second call creates a new document with a text _id…
Jim
  • 83
  • 9
3
votes
1 answer

Cannot loop MongoDB Collection Functions

For some reason, I cannot loop collection.count. It keeps printing filename[5] 5 times instead of starting at 1 and going to 5. This makes no sense because I can manually copy and paste this function 5 times and it will work, but when in a for…
krikara
  • 2,395
  • 10
  • 37
  • 71
3
votes
2 answers

Express.js - Filter a mongodb id in the URL

This question inspired by this post but in my case I need to filter MongoId. Is it possible to make filtering easily that the below because I need use it in each route? app.post('/:mongoId(^[0-9a-fA-F]{24}$)', function(req, res){ // Send query…
Erik
  • 14,060
  • 49
  • 132
  • 218
3
votes
1 answer

Node.js, MongoDB - Inserting/updating multiple documents and sending a single response

I'm trying to develop a synchronization server (think: SVN like) that accepts one or more documents (JSON string) from the client in one request (JSON stringified array of JS objects), inserts/updates them into mongodb and sends one response - which…
techfoobar
  • 65,616
  • 14
  • 114
  • 135
3
votes
3 answers

Should MongooseJS be emitting events on replica set disconnection?

With a single server setup, I receive events from the driver. mongoose.connect('mongodb://localhost/mydb'); mongoose.connection.on('disconnected', function() {...}); mongoose.connection.on('error', function(err) {...}); When using a replica set…
MoatMonster
  • 267
  • 1
  • 2
  • 7
3
votes
1 answer

MapReduce, MongoDB and node-mongodb-native

I'm using the node-mongodb-native library to run a MapReduce on MongoDB (from node.js). Here's my code: var map = function() { emit(this._id, {'count': this.count}); }; var reduce = function(key, values) { return {'testing':1}; …
Assaf Hershko
  • 1,846
  • 4
  • 18
  • 20