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

Dynamic collection.find $or condition in NodeJS

I need to generate an $or filter from passed strings in an array to select documents from a 20K documents' collection. So I wrote the following function which generates the $or condition: function orConditionCreator(attName, tagsArray) { var…
Haywire
  • 858
  • 3
  • 14
  • 30
0
votes
0 answers

Mongodb-native (node.js): Query Date range

I'm using node 0.10.21 and mongodb-native (aka require('mongodb')). The problem I'm having is, that I cannot aggregate a timeseries collection AND use match to select a certain time frame: var start = new Date(); //just demo, the start date is…
Steffen
  • 589
  • 6
  • 16
0
votes
1 answer

How do I merge 2 subproperties in MongoDB?

I have 2 subproperties of a document and want to move all properties from one to another, but AFTERWARDS I want to erase the empty property. Now I know the $rename command can be used to move each property from one place to another, but I also want…
Discipol
  • 3,137
  • 4
  • 22
  • 41
0
votes
0 answers

How do I limit the properties of a query based of a common subproperty?

Given the schema: { _id: ObjectID, city: { units: { abc: {}, def: { tuid : String }, ... xxx: { tuid : String } } } I would like to return, for a particular _id, all the properties of units who's…
Discipol
  • 3,137
  • 4
  • 22
  • 41
0
votes
1 answer

What does MongoDB findAndModify do with fields that are in the old document, but not the updated document?

If I call findAndModify, and a document matches the query, but the existing document has fields that the doc does not, will the old fields still exist in the new document, or will they be removed? I've checked the findAndModify docs and the…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
0
votes
1 answer

How do I $inc an entire object full of properties without building the query with a loop?

I have a collection of documents for the form: { name:String, groceries:{ apples:Number, cherries:Number, prunes:Number } } Now, every query I have to increment with positive and/or negative values for each element in "groceries". It is not…
Discipol
  • 3,137
  • 4
  • 22
  • 41
0
votes
1 answer

What is the efficient way of dynamically creating and reusing multiple mongodb connections in nodejs?

I am using mongodb 2.2.3 and nodejs 0.10.5. I am creating an app where I am connecting to different mongodb instances on different hosts. What is the most efficient way of dynamically creating and reusing the different connections ? For example I…
Mahasooq
  • 209
  • 2
  • 12
0
votes
1 answer

Contains Query into MongoDB Array using Mongoose

I'm trying to query into following document and want to list all document which contains TaxonomyID "1" in "TaxonomyIDs" field. ... "Slug" : "videosecu-600tvl-outdoor-security-surveillance", "Category" : "Digital Cameras", "SubCategory" :…
Nilay Parikh
  • 328
  • 3
  • 14
0
votes
1 answer

node-mongodb-native does not recover on replica set primary network failure?

Our MongoDB setup uses three replica set shards. Each webserver runs a mongos instance locally, and the client node.js processes connect through that using Mongoose (3.6.20) and node-mongodb-native. So node-mongodb-native just connects to mongos on…
Brett
  • 3,478
  • 1
  • 22
  • 23
0
votes
2 answers

In nodejs with MySQL

I am Using Nodejs with MySQL. But problem is that My MYSQL Connection Password Able to see in browser, With this any user get my my SQL username and Password. Is it possible no one can see my MySQL Connection permanent as its is a server side. Can…
0
votes
0 answers

How to validate multiple values at once and dose it need for MongoDB

I have the following express POST route handler that accepts GET and POST data something like this: app.post('/handler/:id/:type', function (req, res, next) { var id = req.param('id'); var type = req.param('type'); var body = req.body; …
Erik
  • 14,060
  • 49
  • 132
  • 218
0
votes
2 answers

Replace ObjectID method for node-mongo-native

The objectID object used in mongo seems to be a little difficult to deal with when it comes to passing it back and forth with json and communicating with other applications. It seems that to use it, I have to convert back and forth between the…
RobKohr
  • 6,611
  • 7
  • 48
  • 69
0
votes
0 answers

javascript wierdness returning value

Hi I am new with javascript, there is a problem that is driving me crazy: what is the difference between an object staticly declared as this one : {$or:[{tc_clpar_id:4,tc_par_id:{$in:[79,80]}},{tc_clpar_id:5,tc_par_id:{$in:[105,106]}}]} and an…
arpho
  • 1,576
  • 10
  • 37
  • 57
0
votes
1 answer

I can't seem to retrieve data from mongodb using Node.js

I'm having trouble retrieving data from a mongodb collection which I believe has been inserted correctly. So here is my example code... var db = require('./database'); module.exports = function (app) { app.get('/db', function (req, res) { …
Integralist
  • 2,161
  • 1
  • 32
  • 50
0
votes
1 answer

How do I fill a collection with millions of dummy documents without a million inserts?

I wish to fill a collection with user accounts, full of dummy data ofc. Now I don't expect calling 1 mil inserts will be smart, so I require how to do it database-side. I sort of remember something about doing javascript in the database and perhaps…
Discipol
  • 3,137
  • 4
  • 22
  • 41