Questions tagged [mongojs]

MongoJS is a Node.js package to access MongoDB.

References:

306 questions
2
votes
1 answer

MongoDB: Adding an array into an existing array

I'm trying to add an "Instructors" array into an already existing "Camps" array. The hierarchical structure looks something like this: owner = { email : 'john.smith@gmail.com', password : 'mypassword', firstName : 'john', lastName…
cpeele00
  • 883
  • 4
  • 14
  • 29
2
votes
1 answer

Retrieving Dates in MongoJS

I'm trying to store and retrieve a date in mongojs. Here's how it's saved: var game = { startedOn: new Date() }; db.games.save(game); When I fetch it, the date is not a date anymore. It's some kind of wrapper around a date. The _d field seems to…
bendytree
  • 13,095
  • 11
  • 75
  • 91
2
votes
1 answer

Mongojs: Ignoring Duplicate Objects Insertion

I have this Node.js application that it gets a large sum of JSON data with unique ids and then inserts them into a MongoDB using Mongojs. The problem is that in this large array of data, there might be some duplicate documents! so when using Mongojs…
Hamed
  • 869
  • 10
  • 26
2
votes
1 answer

Mongojs - how to push to array?

I have the following code: db.users.save({ username: "admin", array: [{ foo1: "foo1", foo2: "foo2" }, { bar1: "bar1", bar2: "bar2" }, { cell1: "cell1", …
julian
  • 4,634
  • 10
  • 42
  • 59
2
votes
1 answer

MongoJS increase pool size

I am building a simple application using Node.js and MongoDB through the MongoJS driver. I am aiming at some heavy load (round 10000 users in 10 mins with sessions of approx 30s) I am using connection pooling, and by default mongojs creates 5…
jaja
  • 352
  • 3
  • 10
2
votes
2 answers

Javascript (mongojs): Return a value in a function

I'm working with mongojs and I have to retrieve a field from an object taken from mongodb. I can not understand how to return the field: function retrieveVertById(id){ var result = []; db.clusters.find({id: id}, function (err, clusters){ …
2
votes
2 answers

Connecting to mongoHQ with mongojs on heroku

I am trying to connect to mongoHQ from my node.js app. Here is the code I am using: var databaseUrl = "mongodb://fishcuss:MyPassword@alex.mongohq.com:10015/app9759558" var collections = ["users"] var db = require("mongojs").connect(databaseUrl,…
2
votes
1 answer

collection.find mongojs synchronous callback

I'm trying to write my own wrapper for the mongojs collection.find method that should return the collection items selected by the specified query (querying isn't implemented yet, it should simply select all results). The problem is that I'm not…
Pascal Bayer
  • 2,615
  • 8
  • 33
  • 51
2
votes
1 answer

Run MapReduce from MongoJS

Is it possible to run a mapreduce job using mongojs in a node application. I realize that using mapreduce in the web server code is not the most efficient way to do this but it is for testing purposes.
benhoman
  • 21
  • 2
1
vote
1 answer

How to fetch the last n months record(consider only the last entry per month) in MongoDB

I am new to MongoDb. I need help to fetch the last n month record, there might be multiple entry per month but the query needs to return only the last entry per month. For e.g lets say if n is 3 and userId is userId1 (that means return last 3 month…
sham
  • 422
  • 4
  • 18
1
vote
4 answers

Can't get mongojs (node-mongodb-native wrapper) to work on Ubuntu 10.10

I used npm install mongojs to get the wrapper, but when trying to run my app I get the following error: node.js:195 throw e; // process.nextTick error, or 'error' event on first tick ^ Native bson parser not compiled, please…
Tim Skauge
  • 1,814
  • 2
  • 23
  • 35
1
vote
1 answer

await doesn't wait for function to end

I know this has been asked a lot but I can't seem to use the existing answers to get my code to work. I am trying to use mongojs to make a single query, then put the results in a global (relative to the scope) variable to avoid nesting multiple…
1
vote
0 answers

Which version of mongojs is compatible with node js version 10.15

I am using mongojs version 2.6.0 with node version 10.15. How can I find out which mongodb version is being used? The mongodb compatibility version mentions that >=3.0 version is required to work with node version 10.15
Alice
  • 271
  • 2
  • 12
1
vote
2 answers

How to set remote connection to database via Mongojs

i need set remote connection to MongoDB, but i need make it via mongojs. var docdbconn = mongojs('mongodb+srv://mylogin:mypassword@cluster0-m1s1a.mongodb.net/nameofdatabase?retryWrites=true'); and usually i get next error: MongoError: failed to…
Max
  • 781
  • 7
  • 19
1
vote
1 answer

Array Filters (mongodb) does not work in my nodejs backend

Am using it with nodejs in my backend. Got the following query: db.conversations.update( { convoId: convoId }, { $set: { "ids.$[elem].read" : true } }, { arrayFilters: [ { "elem.id": userId } ] }, (err, data) => { if(err) { …
Favo SA
  • 13
  • 3