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

How to save a modified object in mongodb using Node.JS Driver

I want to find, modify and afterwards save an object in MongoDB. It looks like that: var message = req.body; db.collection('user', function(err, collection) { collection.findOne({'facebook_id':req.params.facebook_id}, function(err, item) { …
Luxori
  • 115
  • 7
0
votes
1 answer

Access and modify extern variable in MongoDB request

I have a problem in a nodeJS app with mongoDB, i'm trying to do a forum and for each topic i want a button to display every sub topics. So i need to get everything in the request: One array with main topics Another map array with ['topic1']…
Leeios
  • 45
  • 1
  • 7
0
votes
2 answers

MongoError: not authorized for insert/query; stackato

This is a part of a corporate project. I am trying to host an application on the stackato server put up by my company. My app has a node framework with mongodb support. I wrote a simple script that tries to connect to the db service and insert a…
user2938718
  • 13
  • 2
  • 4
0
votes
1 answer

How to check if mongos connection still alive in Node.JS?

Let's imagine we have Node.JS app which is connecting to the Mongos process. But suddenly Mongos failed. How our app could now about it? var db = null; mongo.MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, mydb) { if(err)…
0
votes
1 answer

Nodejs Mongo date queries relative to database's date

If I perform the following update from my NodeJS app: db.collection('test').update({name: 'some_name'}, {$set: {update_time: new Date()}}, {w:1}, function(err) { console.log('successfully updated'); }); I believe it will use the NodeJS app's…
Will I AM
  • 220
  • 1
  • 9
0
votes
0 answers

How to completely remove a document in MongoDB

I find that when I run the remove() command on mongodb-native for node.js, the document is removed but it's _id remains. So after performing a bunch of deletes I'm stuck with these empty objects with only an _id. This is odd considering if I call…
Josh Elias
  • 3,250
  • 7
  • 42
  • 73
0
votes
3 answers

MongoDB: Find only inserted items upon upsert

I try to fetch feeds from multiple endpoints periodically and looping these batch of items and do update with upsert:true. For each item I check the URL of an item if it's already in myCollection, it updates the "end_date" if it's new, it gets…
user3211198
  • 223
  • 1
  • 5
  • 14
0
votes
1 answer

Mongoose numChanged argument?

How does mongoose determine the number of documents that were changed in an .update()? Does the node-mongodb-native driver return that information? I can't seem to find this in the docs.
paulkon
  • 1,755
  • 2
  • 20
  • 34
0
votes
0 answers

Express - Getting proxy error when trying to insert record to MongoDB

I want to insert a record into my mongoDB collection, then retrieve it. Using express.js exports.index = function(req,res){ var MongoClient = require('mongodb').MongoClient; MongoClient.connect(mongourl, function(err, db) { var…
user2422960
  • 1,476
  • 6
  • 16
  • 28
0
votes
1 answer

Access db without leaving empty db behind.[node-mongodb-native]

I want to make sure some database does not yet exist in mongodb but anytime I access db object an empty database is created. Using node-mongodb-native driver: var MongoClient =…
0
votes
0 answers

Ok to validate within query document?

Which is a better trade-off for validation of a common field? user.groups = [someIds] db.posts.findOne({ _id: someId, group: someOtherId }) if there's no document returned then I can assume the user is querying for a document outside of their…
paulkon
  • 1,755
  • 2
  • 20
  • 34
0
votes
1 answer

Trouble getting a response from cursor.toArray() in Mongo/Node

node 0.10.24 + mongo node driver 1.3.23 on 32 bit linux My callback here is never getting executed. console.log(record_collection); record_collection.find({}, function (error, cursor) { console.log("record_collection.find() returned"); …
Joe Beuckman
  • 2,264
  • 2
  • 24
  • 63
0
votes
1 answer

mongoskin db.collection.find().toArray() don't work in os x

why this code work well in linux (ubuntu12.04). don't work in os x 10.8/9 (node version, mongoskin version is the some) var mongo = require('mongoskin'); exports.test = function(req, res) { var db = mongo.db('localhost:27017/btc', {safe:…
zhaoyou
  • 308
  • 4
  • 19
0
votes
1 answer

Node mongodb-native: insert an array of strings as documents

node: 0.10.13 mongo: 2.4.1 mongodb-native: 1.3.23 Question: How do I insert an array of simple strings as new documents with a single call? I don't want to convert it before. I am looking for some mongo magic here. The $push, $each things…
angabriel
  • 4,979
  • 2
  • 35
  • 37
0
votes
1 answer

mongodb native how to work with query

I'm trying to retrieve data from my mongolab DB using Node-mongodb-native var findAll = function () { var ddocs; collection.find({}).each(function (arr, docs) { ddocs = docs; }); console.log(ddocs); }; But it seems that when I…
TzelonM
  • 41
  • 3