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

nodejs mongodb separate ec2 instances

i have a test application running successfully using the node-mongodb native driver with the node.js and mongod running on the same instance. Now i am trying to get into production phase and have set up 2 separate ec2 instances 1 for node another…
user1583920
  • 227
  • 4
  • 11
0
votes
1 answer

Pull object from an array with node-mongodb-native

I'm struggling with a simple operation with the mongodb native driver for nodejs. Here is my mongo document: { "_id" : 1, "foo" : "bar", "baz" : [ { "a" : "b", "c" : 1 }, { …
xavier.seignard
  • 11,254
  • 13
  • 51
  • 75
0
votes
2 answers

find object inside JSON using nested ID

i have a mongo collection like this {"stores": [{"name": "foo", "songs": [ {"id": "", "name": "", "artist": "", "category": "", "tags": []} ], "songsSchedule": [ { …
jtomasrl
  • 1,430
  • 3
  • 13
  • 22
0
votes
0 answers

limit mongo search by age?

I'd like to only get documents that were created in the last 24 hrs, is there a way to limit queries by age? Can I use the doc ids? a limit query? Should I add a date field and use min/max? Some other way? Thanks for any info!
boom
  • 10,856
  • 9
  • 43
  • 64
0
votes
2 answers

How should I keep an index of user info?

Say I need every users name often. Instead of querying for every document and then plucking this attribute what is the best way to keep an index I can quickly call? Should I add another document that is just an array of these attributes and then…
boom
  • 10,856
  • 9
  • 43
  • 64
0
votes
1 answer

Confused about node-mongodb-native syntax

I'm just getting into node and mongodb and came across the first obstacle. I'm walking through a tutorial where the code looks something like this: var db = new mongo.Db("database", new mongo.Server(host, port, {})); db.open(function(error){ …
Vlad
  • 8,038
  • 14
  • 60
  • 92
0
votes
1 answer

nodejs mongodb Gridstore.exist infinite loop

I am trying to use GridStore of mongodb, I have a wierd infinite loop problem when I try the following code GridStore.exist(db, req.params.filename, function(err, result){ The following is the whole code and its debug output var express =…
kkites
  • 349
  • 1
  • 7
0
votes
2 answers

Structuring database object with mongodb-native bindings for node.js

I'm working on creating an object that I can reuse throughout my server. However, with the following example, I get, what appears to be two calls to 'create'. Any ideas why? Can I structure this better. var mongo = require('mongodb'); var Server =…
kenneth koontz
  • 849
  • 1
  • 8
  • 16
0
votes
1 answer

Error with ReadPreference using Mongos in node-mongodb.native

I'm having an issue with GridFS while using MongoS for node-mongodb-native. I opened an issue in github, but it's really just a symptom of the problem. The error that doesn't get caught complains about ReadPreference not being set. I can't find a…
Justin Thomas
  • 5,680
  • 3
  • 38
  • 63
-1
votes
1 answer

Nodejs Mongodb driver: how to combine index hint and projections

Struggling to combine index hints and query projections with the Nodejs driver. This works if we only include a hint: db.collection('battle').find({}, {'hint': 'myindex'}).toArray(); This works if we only include a…
Samuel Goldenbaum
  • 18,391
  • 17
  • 66
  • 104
-1
votes
1 answer

MongoError: listCollections failed

I have setted up a mongo database, which works with authentication. I'm trying to copy a database using mongodb native driver. The problem is my command get rejected as : MongoError: listCollections failed: { ok: 0.0, errmsg: "not authorized on…
Orelsanpls
  • 22,456
  • 6
  • 42
  • 69
-1
votes
1 answer

Memory leak using mongodb (and cheerio, request, and async.js)

I am on scraping actions on nodejs, I am using request to connect to site, cheerio to access to the data and mongodb to store the data extracted. Also I am using async.js to avoid infinite recursion. I have got a memory problem because my process…
-1
votes
1 answer

Passing through MongoDB document value to EJS table

I'm fairly new to node.js and MongoDB so bear with me. I have a form which stores details into a MongoDB collection; I then query this using .findOne (for now). I'm basically trying to pass this value into my index.ejs file and display it as part of…
Connor McFadden
  • 441
  • 1
  • 4
  • 20
-1
votes
1 answer

Express, Node error control flow

Examining the code below, how is it possible that the try/catch block is catching the "Route Error"? My understanding is that the callback registered to the '/' route is executed on the main event loop and as such the exception cannot be caught by…
fthinker
  • 646
  • 2
  • 9
  • 17
-1
votes
1 answer

Insert returning an array with 1 object

I am making an insert with native mongodb for nodejs and in some cases, using insert returns me an array with the object I inserted, but sometimes it does not. I don't understand why it is inconsistent like this, I only want the object i inserted…
Discipol
  • 3,137
  • 4
  • 22
  • 41
1 2 3
32
33