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

How to set the safe variable to false on mongoskin?

I'm measuring the performance difference of insert between a connection with safe: true and another with safe: false. However, changing the safe variable does not seem to affect the performance at all. var dbURI = 'mongodb://' + 'user' + ':' +…
jeebface
  • 841
  • 1
  • 12
  • 29
0
votes
2 answers

sorting mongodb through node.js

I want to sort the result of the mongodb query I was doing some practice on it but I can't get the result as it was expected to do so here is the code ro.find(function(err,objs){ if(err) res.write('{"Find Error":"'+err.err+'"}'); else { …
Bilal Naqvi
  • 140
  • 1
  • 11
0
votes
1 answer

Writing a complex if condition in mongoose efficiently

I have a set of conditions on my node app where I am trying to implement the following if block - if(((public==true)&&(varA=="something" || varB == "something")) || (public==false)&&(varA=="something" || varB == "something")&&(varc ==…
Harshit Laddha
  • 2,044
  • 8
  • 34
  • 64
0
votes
1 answer

Return counter in db.collection.count()'s callback doesn't work, why?

I want to track the number of documents I have within a collection in a node.js server using mongodb driver. I can insert, delete and update propperly but when I try to count, it works until I try to store that value, moment in which it returns…
Ruben Marrero
  • 1,392
  • 1
  • 10
  • 23
0
votes
2 answers

Attempting to return collection with node.js hangs system

I have a node.js application that uses a mongodb database that I've created. Within it, I have a simple collection named comments with the contents { "author": "me", "comment": "this is a comment" } when I call db.comments.find({}). However, when I…
canadiancreed
  • 1,966
  • 6
  • 41
  • 58
0
votes
1 answer

Bluebird Promisfy.each reference error?

Am new to promisification and am not quite sure if .then and .each carry variables across the entire promise. Also, I clearly define docReplies in the fourth line, yet the console logs: Possibly unhandled ReferenceError: docReplies is not…
StackThis
  • 883
  • 3
  • 15
  • 45
0
votes
1 answer

Mongoose error : Cannot read property 'pluralization' of null

I've just started learning Nodejs and i've been trying to create a schema to store emails and passwords but when i start server.js i get this d:\Make your CV\node_modules\mongoose\lib\index.js:357 ion' in schema.options))…
Sam Nasser
  • 311
  • 5
  • 13
0
votes
3 answers

Can't find by _id in mongodb using nodejs driver 1.4

I have a very basic app, that creates reports. I have a piece that is supposed to query and pull by _id from a mongo database. No matter what I cant get the find by _id to work. Mind you, just find() works when I need to show all reports. I've…
Steve Liu
  • 9
  • 4
0
votes
1 answer

Mongoose - posting an object array to Mixed

Stumped with this one: I have a pre-built object set called a "step" containing a bunch of sub-objects. It's already sanitized and set up properly, so I want to just shove it into Mongo whole. I've got a Mongoose schema looks like this: var…
pretentiousgit
  • 165
  • 2
  • 9
0
votes
1 answer

How to promisfy MongoDB/Mongoose .findOne before .push, in an array.forEach?

Have looked through the bluebird readMe examples, and am still wondering how to implement/convert some async code to involve promises with .then.. There are a number of ifStatements in here, though the main point is that while looping through the…
StackThis
  • 883
  • 3
  • 15
  • 45
0
votes
1 answer

mongoclient remove collection nodejs

I am trying to remove the entire collection, but it is not working with the below nodejs code. The same works within mongodb using command [db.collection.remove()] There are no errors, but the below returns count of events as…
0
votes
1 answer

Better approach using MongoDB native driver in NodeJS

Here is the code snippet on which my question is var MongoClient = require('mongodb').MongoClient , Server = require('mongodb').Server; var mongoClient = new MongoClient(new Server('localhost', 27017)); mongoClient.open(function(err,…
Karthic Rao
  • 3,624
  • 8
  • 30
  • 44
0
votes
0 answers

Query all documents from MongoDb with Node

For the following GET request, I am trying to get the server to return all "Musician" documents, which I would then format on display on the musicians-all jade template page. app.get("/musicians/all", function(req, res){ var id = req.params.id; …
jaja
  • 127
  • 10
0
votes
0 answers

Mongoose sub-schema shows '[object Object]' in document.

From a query done with the mongoose api on a Mongodb, I have what appears to be a json object. But...it's not usable as json Object. What is this and how do I make it a usable json object? JSON.stringify(result) and JSON.parse() are not effective. …
dman
  • 10,406
  • 18
  • 102
  • 201
0
votes
1 answer

Node and Express - Make Database available to all pages in a subdirectory

How can I make these two database collections available to all paths with the extension /auth? (For example: /auth/opentickets, /auth/closedtickets, /auth/editdeveloper) Right now, I would have to do add this to every event handler. Is there a…
user2916134