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
0
votes
1 answer

Check for opening hours- MongoDB

Can I find whether library is open or closed now without changing following schemas: "openhours" : { "sun" : { "day" : "Sun", "active" : true, "open" :…
Ritesh Kumar Gupta
  • 5,055
  • 7
  • 45
  • 71
0
votes
2 answers

Set variable equal to mongodb key value

var userLat = db.collection('users', function (err, document){ document.findOne({_id: loggedUserID}, function(err, docs) { console.log(docs.currentUserLat); }) }); This is my code, I'm trying to get the value that's console logged…
user2947979
  • 35
  • 1
  • 6
0
votes
1 answer

elemMatch search on array of subdocument

How to do search using elemMatch on array of SubDocument? I have document called ReportCollection with elements such as:- /* 0 */ { "_id" : ObjectId("5507bfc435e9470c9aaaa2ac"), "owner" : ObjectId("5507bfc31e14d78e177ceebd"), "reports" :…
Anand
  • 4,523
  • 10
  • 47
  • 72
0
votes
1 answer

Can't connect to MongoDB database with NodeJS native driver

I have a NodeJS app in which I need to connect to to MongoDB databases - one a single server set up, and the second from a replica set. I connect to the next one just fine, but when connecting to the second one - I get the following…
byteSlayer
  • 1,806
  • 5
  • 18
  • 36
0
votes
1 answer

MongoDB retrieval error

I am retrieving a document from MongoDB using find() in Node.js, while printing the result I am not getting the retrieved values. Here my code.. db.collection("Product").find({'entry_id':entryID},function(err, result) { …
Jayanth
  • 485
  • 3
  • 9
  • 17
0
votes
0 answers

Unable fetch collection on {strict: true} option

When trying collection with test.collection.col name returns empty array: db.collection('collection.col', {w: 1, strict: true}, function (err, collection) { if (err) { console.log(err); // Collection collection.col does not exist.…
Erik
  • 14,060
  • 49
  • 132
  • 218
0
votes
1 answer

Extending MongoDB's "save" method in nodejs

In our app, we have a large document that is the source of most of our data for our REST api. In order to properly invalidate our client-side cache for the REST api, i want to keep track of any modifications made to teh document. The best we came…
Zak Kus
  • 1,503
  • 3
  • 15
  • 28
0
votes
0 answers

Node Mongo inserts start to fail silently after a few minutes

I am running a GPS listener program. It receives data from GPS devices, decodes, prepares a final data object and then stores the data in Database. I am trying to insert documents to mongodb from nodejs with the following code - (using node mongodb…
Sudipta
  • 1
  • 1
0
votes
1 answer

Can't get MongoDB update query to work in Node.JS

I've been through the docs, tutorials and SO. I just can't seem to find the right answer on how to properly update an entry that's already in the database. I can insert data just fine but the second I try to update it using the below query, it…
Entryton
  • 57
  • 1
  • 2
  • 9
0
votes
1 answer

How to create global objects in MongoDB's V8 engine to be accessible via db.eval?

I'm trying to use MongoDB server-side JavaScript in my nodejs/node-mongodb-native project and just interested how could I save my custom functions in global context of MongoDB and get access to them from db.eval script? Let's say I have the…
Erik
  • 14,060
  • 49
  • 132
  • 218
0
votes
0 answers

How to load some JavaScript file in node-mongodb-native?

I use node-mongodb-native in my project and I need to load some JavaScript file with my custom functions like in the following tutorial My code for connecting to database looks like the following: var mongoClient = new MongoClient(new…
Erik
  • 14,060
  • 49
  • 132
  • 218
0
votes
1 answer

$geoNear aggregation ignoring maxDistance

The following query should return cities within a distance of lng and lat. The city collection has an 2dsphere index on its gps field. City.native(function(err, collection) { collection.aggregate([{ $geoNear: { near: { …
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
0
votes
0 answers

node-mongodb-native manually aborting running queries

I'm wondering what the most efficient way to manually abort a running query with the official node client is. In my current code I am creating a new DB connection for each remote client and then simply closing those connections if the client…
pospi
  • 3,540
  • 3
  • 27
  • 26
0
votes
1 answer

Mongodb multiple indices per field

To enable unique index in node I do: City.native(function(err, collection) { collection.ensureIndex({ 'name': 1, }, function(err, result) { //nothing }); }); But I would like to enable text index on name also. So after…
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
0
votes
0 answers

Node npm start - cannot find module 'mongodb'

I was following the Christopher Buechler tutorial (http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/)for getting started with Node/Express/MongoDB. I made it to Step 6 where where I'm trying to display the userlist on the local host but…
rashadb
  • 2,515
  • 4
  • 32
  • 57