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

Return variable from method in a loop

Something like this var joined = function(arr) { var res = []; for (var i in arr) { var u = DB.getUser(arr[i].user_id, function(user) { return user; }); arr[i].user = u; res = arr[i]; } …
user2194521
  • 119
  • 8
0
votes
0 answers

does the Node.js driver for MongoDB support functions as selectors?

does the Node.js mongoDB driver support $where predicates in remove(…)/count(…) operations? it seems to work for a regular find(…), but i receive unexpected results (false positives) with other operations.
RubyTuesdayDONO
  • 2,350
  • 2
  • 25
  • 37
0
votes
1 answer

Mongodb node authentication says not authorized yet logs in

I have the following, & im using it to log in and do a query, so I get through db.authenticate, but when I do my query I get thrown: MongoError: unauthorized data ns:data.data lock type:0 client:127.0.0.1] name: 'MongoError' } As ridiculous as the…
Tarang
  • 75,157
  • 39
  • 215
  • 276
0
votes
2 answers

Something wrong with mongo (1.4.4) request

When I query like this : collection.find({ "position": { $in: [ 1, 2 ] } }).toArray().... I get the right result, when I use $and or $or , for example: collection.find({ $or: [ { "position": 1 }, { "position": 2 } ] }).toArray()... I always get…
slezadav
  • 6,104
  • 7
  • 40
  • 61
0
votes
2 answers

Is it possible to have object with value only?

I have this piece of code : db.collection('coders', function(err, collection) { collection.find(toFind).toArray(function(err, items) { res.send(items); }); where toFind is something like…
slezadav
  • 6,104
  • 7
  • 40
  • 61
0
votes
1 answer

Mongodb / MongoHQ connection from Nodejitsu

I seem to be having trouble connecting to MongoHQ (via MongoSkin) on jitsu. I can connect from localhost though, and all I'm doing is changing my env var and jitsu deploying. It's just strange that it works locally but not deployed. I had talked…
cja
  • 367
  • 1
  • 3
  • 7
0
votes
2 answers

When does node-mongodb-native hits the database?

I have trouble understanding when exactly the database is hit when using node-mongodb-native. Couldn't find any reference on that. As everything is callback based, it gave me the feeling that every single call hits the database ... For example, are…
sebpiq
  • 7,540
  • 9
  • 52
  • 69
0
votes
1 answer

mongo native not creating data

Im trying to create data if a facebook id exists in the database else create new data, however the first condition works fine but when its creating data nothing happens, ony get connot read property 'provider' of null even i hard code a provider…
nihulus
  • 1,475
  • 4
  • 24
  • 46
0
votes
1 answer

finding the documents containing a value closest to the parameter passed in mongodb+node.js

I have a mongodb collection called lights and a document in this collection looks like, { "_id": "50eea4a53004cc6233d12b02", "Physicalentity": "Light", "Sensor": "Tinkerforge", "Unit": "Lux", "value": "47.2", "time":…
spaniard89
  • 307
  • 1
  • 6
  • 18
0
votes
2 answers

MongoDB GridFS driver in NodeJS overwrites files with the same name

I have the following code (removed error checking to keep it concise) which uses the node-mongodb-native. var mongo = require('mongodb').MongoClient; var grid = require('mongodb').GridStore; var url =…
BytesGuy
  • 4,097
  • 6
  • 36
  • 55
0
votes
1 answer

Something is wrong with cursor

I try to fetch two documents one by one. I set batchSize to 1 for my test purposes. And I cant't fetch the second document. However, when I set batchSize to 2 it returns me the second doc without…
Andrey Kon
  • 747
  • 2
  • 6
  • 16
0
votes
1 answer

node.js, node-mongodb-native, DRY connections?

I currently have the following code in every file under ./routes. var mongo = require('mongodb'); var config = require('../config/config'); var Server = mongo.Server, Db = mongo.Db, var server = new Server(config.DatabaseConfig.host,…
az_
  • 1,493
  • 1
  • 16
  • 24
0
votes
1 answer

Limiting the number of documents to be returned while calling the find() function on a collection in mongodb

As my question suggest, I would like to limit the number of documents displayed when the find() function is called on a collection like this: exports.findAll = function(req, res) { db.collection('temp', function(err, collection) { …
Spaniard89
  • 2,359
  • 4
  • 34
  • 55
0
votes
3 answers

Inserting a document into an collection of mongodb database via node.js

I have a small web server written using node.js, express and serial port which would constantly listen to an temperature sensor attached to the mac via USB. The code is as follow: var serialport = require("serialport"), // include the…
Spaniard89
  • 2,359
  • 4
  • 34
  • 55
0
votes
1 answer

How would I remove an item from an array with mongo?

I'd like to atomically remove an item from an array. I was looking at using findAndModify but I'm not sure how that would work. Any direction on how to atomically remove an item from an array in a doc would be much appreciated! Thanks!
boom
  • 10,856
  • 9
  • 43
  • 64