Questions tagged [mongojs]

MongoJS is a Node.js package to access MongoDB.

References:

306 questions
2
votes
1 answer

Unable to query MongoDB using a localhost URL and MongoJS

This is the tasks.js code I'm trying to run: /*jslint node:true*/ var express = require('express'); var router = express.Router(); var mongojs = require('mongojs'); var db = mongojs('mongodb://localhost:27017/tasks',…
user4537828
2
votes
2 answers

Read from secondary replica set in mongodb through javascript

I have 2 mongo instance running in 2 different servers (one primary and other secondary); I am able to retrieve a document from the primary server using this connection code: var db = mongojs('user:pswd@localhost:27017/mydb?authSource=admin'); But…
2
votes
0 answers

Mongo "not authorized for query" on user defined table while authenticated as dbOwner

I'm using is mongojs 2.3.0 to connect to a MongoDB cluster running 3.0. The user credentials I'm using to connect are for a user that has dbOwner privileges (so they should have read/write permissions for all collections). The driver successfully…
ttacon
  • 503
  • 3
  • 9
2
votes
1 answer

Can't connect from mongojs but command line is OK

I use mongojs to connect my Node.JS to MongoDB. When I do mongo easymail -u admin -p PWD --authenticationDatabase=admin from bash, everything goes right. But : mongodb://admin:PWD@localhost:27017/easymail?auto_reconnect=true&authSource=admin give…
izanagi_1995
  • 94
  • 1
  • 8
2
votes
3 answers

Mongojs: Remove with sort and skip

I have been unable to find any documentation or examples on how to do this, but surely it's possible. Basically, I want to keep 20 of the most recent records. I want to order by a date (descending), skip 20, then remove the leftovers.
Alex311
  • 378
  • 3
  • 12
2
votes
1 answer

mongojs implementation new bie

Hi I am new to MongoDB and NodeJs. I am using "mongojs" module to simple read the data from mongodb. The code goes as follows: var dbname = 'XXXX'; var databaseUrl = 'mongodb://localhost:27017/'+dbname; var collections =…
Norah
  • 65
  • 1
  • 5
2
votes
2 answers

Mongodb find and then update

I want to run a query which gets all the documents which has the 'active' field as true and run a custom function on them which checks if the 'date' field inside the document is older than 10 days. If both of them are true then it will make the…
shash7
  • 1,719
  • 1
  • 18
  • 20
2
votes
1 answer

MongoJS limit and Skip

I need to use limit and skip to get some record from mongo. I am using MongoJS with NodeJS but below given is not working. Below is an example: db.users.find(function(err,doc{ console.log(doc); })).skip(2).limit(2); also I have tried something…
Vivek Panday
  • 1,426
  • 2
  • 16
  • 34
2
votes
2 answers

MongoDB query executes in 1ms on mongo-shell but takes 400ms and more on NodeJS

I have a large MongoDB collection, containing more than 2GB of raw data and I use a very simple query to fetch a specific document from the collection by its Id. Document sizes currently range from 10KB to 4MB, and the Id field is defined as an…
iMoses
  • 4,338
  • 1
  • 24
  • 39
2
votes
1 answer

Mongojs : wrong ELF class: ELFCLASS32 nodejs application in openshift

I am having a nodejs(expressjs) application which runs fine locally but when I deploy it to Openshift i got an exception when i check the log file it has the following error when including this line in server.js. var mongojs =…
2
votes
1 answer

How to simulate an 'error' event on MongoDB

I'm trying to write a test case for a NoFlo component (written by a colleague) - where the component has a "connect" inPort and an "error" outPort like: var self = this; // a NoFlo Component var mongodb = null; self.inPorts.connect.on("data",…
Kenny Ki
  • 3,400
  • 1
  • 25
  • 30
2
votes
1 answer

Mongodb aggregation pipeline new date

I try to use aggregation pipeline to append/create new date based on the previous pipe value and save to a new collection.(see my pipeline below). However, the syntax is wrong and I got an error says disallowed field type Date in object expression…
eded
  • 3,778
  • 8
  • 28
  • 42
2
votes
1 answer

MongoJS Node findOne falsely returns no results

Using MongoJS: https://github.com/mafintosh/mongojs Finds everything db.users.find({}, function(err,users){ if (err) throw err; console.log(users); }) Returns the user. looks great [{ _id: 53f2faa6aed1689e84982b8b, …
2
votes
2 answers

Should I use mongoose if the schema is too dynamic?

What I have understood so far is that the mongoose needs us to define a schema. But what if my schema keeps changing on a per user basis. For instance, let's say there are thousands of users of mobile phones. Each user has a different kind of offer…
Sudhanshu
  • 457
  • 5
  • 18
2
votes
1 answer

Listen for "mongojs" connection errors

Mongojs is thin wrapper for mongodb-native library, but the only problem is that I am unable to listen for errors ? The main errors which needs to be handled are connection erros, could not or lost connection. Here is the example, that I have tried…
Risto Novik
  • 8,199
  • 9
  • 50
  • 66