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
3 answers

Findone for multiple queries not working mongoose

I am using mongoose with nodejs express framework Here is the document in mongo : { "_id" : ObjectId("59c1fe16b68d844d8473c6fe"), …
TGW
  • 805
  • 10
  • 27
0
votes
1 answer

Querying mongoDB document based on Array element

This is one user's notes. I want to query and get only the notes of this use with "activeFlag:1". My query object code is findAccountObj = { _id: objectID(req.body.accountId), ownerId: req.body.userId, bookId:…
Hisham Mubarak
  • 1,559
  • 3
  • 22
  • 28
0
votes
0 answers

Mongodb query on date part

I have the following sample data: var data = [{ "_id" : ObjectId("583f6e6d14c8042dd7c979e6"), "transid" : 1, "acct" : "acct1", "transdate" : ISODate("2012-01-31T05:00:00.000Z"), "category" : "category1", "amount" : 103 }, { …
mo_maat
  • 2,110
  • 12
  • 44
  • 72
0
votes
2 answers

MongoDB query Date field with the server time

I have mongo documents with field containing date that I insert using $currentDate, so the field has the mongo server date when I insert the document. I want to query and filter all documents that the difference between the date field and the…
D. bachar
  • 21
  • 6
0
votes
0 answers

Mongodb: updating multiple docs in a loop?

I did a great effort to find a solution to this common situation, without success. Hoping somebody can help please. Background: A board of messages. Each message has its msg_id. Each user has an id I need to track which user watched which…
ishahak
  • 6,585
  • 5
  • 38
  • 56
0
votes
1 answer

Why I'm getting two responses from find query?

I'm trying to check if user exists in MongoDb. For unknown reason after I found that the user exsists and send response , it's logging me that the user does not exsists app.post("/login", function(req, res) { var userName = req.body.userName; …
user5109370
0
votes
2 answers

How to get cursor.forEach() iterator to wait for promise chain to resolve?

Using node.js mongodb native module I'm trying to use a promisified iterator but it is not waiting for the promise chain to resolve before firing the finalCallback db.collection('items').find({}).forEach(promiseIterator, finalCallback); function…
chovy
  • 72,281
  • 52
  • 227
  • 295
0
votes
1 answer

MongoDB not returning all results with find $in

I have a simple query to find multiple documents matching a field jId. Right now there are just 2 documents. Using node-mongodb-native and calling find with an $in flag limits it to only one though: let collection = db.collection('documents') //…
Tyler
  • 11,272
  • 9
  • 65
  • 105
0
votes
1 answer

how is data transfer between meteor and mongo secure?

How does the server and client connect to the mongo db such that the communication between client--mongo and server--mongo is secure? Is this something meteor already takes care of or is it already default?
Simon
  • 1,681
  • 1
  • 21
  • 34
0
votes
1 answer

How to store large amount of messages for users in MongoDB?

I need to run my cron scripts to update/insert (upsert) threads (emails) for each user. I have collection that is structured such as: { "id" : ObjectId("57d7fc5fd34228c47059"), "id" : "userid", "primaryEmail" : "user@mail.com", …
Kunok
  • 8,089
  • 8
  • 48
  • 89
0
votes
4 answers

Unable to push data into current object inside mongo database

I am using mongodb native and Node.js 6.5.0. I have user object in mongodb which is structured as: { "_id" : ObjectId("57d7d294d96a73d128c46db9"), "id" : "105862592064", "labels" : [ ] } I have a loop (for each user found) get…
Kunok
  • 8,089
  • 8
  • 48
  • 89
0
votes
3 answers

Will huge amount of callbacks break script or continue whenever enough RAM is available?

I have a function that fetches thread (gmail conversation) ids from database and then asks Google API for all data for each thread id. Once it receives a thread object, it stores it to database. This works fine for my inbox which has ~1k messages.…
Kunok
  • 8,089
  • 8
  • 48
  • 89
0
votes
0 answers

Mongodb count performance issues with Node js

I am having issues with doing counts on a single table with up to 1million records. I have a 32 core 244gb ram box that I am running my test on so hardware should not be an issue. I have indexes set up on all of my queries that I am using to…
John
  • 505
  • 4
  • 20
0
votes
1 answer

Mongodb updating parent & parent's parent & so fro

I have a hypothetical model below, with node-mongodb-native-drive A01 has a direct child (A03), a grandchild (A04) and a great grandchild (A05): A01 -> A03 -> A04 -> A05 A02 has a direct child (A06) If a child get a score, all the parents get it.…
Green
  • 4,950
  • 3
  • 27
  • 34
0
votes
1 answer

Optimising mongodb two phase commit queries

I have read the document which suggests a two phase commit pattern for doing multi-document updates. I created an example as below (using node js native drive). // produce collection [{ _id: 'p01', name: 'apple', qty: 10, transaction:…
Green
  • 4,950
  • 3
  • 27
  • 34