Questions tagged [mongojs]

MongoJS is a Node.js package to access MongoDB.

References:

306 questions
5
votes
2 answers

Mongojs & Express - Can't delete by id

I am trying to delete records based on ID. I am sending the ID via the get verb and acessing it from req.params.id. My code isn't working. What am I doing wrong? //delete user router.get('/deleteuser/:id', function(req, res){ var db =…
user2916134
5
votes
1 answer

node program with promises doesn't finish

I cannot for the life of me figure out why this doesn't finish: var pmongo = require('promised-mongo'); var db = pmongo('mongodb://localhost/builder'); var block_id = '538d097bbb12479d0e9f70ab'; var collection =…
Nick Lang
  • 469
  • 6
  • 16
5
votes
1 answer

MongoDB sort by relevance

I am using trying to get documents from MongoDB on node. Let's say documents have the following structure: { "_id": ObjectId, "title" : String, "tags" : Array } I'd like to sort them by relevance - so when I'm looking for documents that…
m1gu3l
  • 763
  • 1
  • 6
  • 19
5
votes
4 answers

get mongodb data to nodejs array?

I'm having trouble getting mongodb data into nodejs array as follow: Test db: { "supportTicket" : "viT8B4KsRI7cJF2P2TS7Pd0mfqaI5rtwf", "msgId" : 1379304604708.0, "username" : "Guest-OSsL2R", "message" : "hello", "_id" :…
Đức Nguyễn
  • 606
  • 3
  • 9
  • 19
5
votes
1 answer

node.js mongojs findOne callback returning error as null

Presently being driven up the wall by this error. I am running a node.js app with the mongojs wrapper for mongodb. I Started mongod on the default port, then ran var db = require('mongojs').connect('localhost:27017/my_db'); var users =…
ejang
  • 3,982
  • 8
  • 44
  • 70
4
votes
2 answers

Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters

This Error is Occurring based on the order of the route/function defined and i have also searched different reasons for this error's occurrence but din't come across this specific reason //Save Task …
Arun3x3
  • 193
  • 1
  • 7
  • 17
4
votes
1 answer

MongoDB multiple collection update

I have a scenario where an API call needs to update two separate collections. If one update fails I need to revert back the first update. How do I ensure that either both the operations complete successfully or none. To help clarify, here's the…
Nil
  • 401
  • 1
  • 6
  • 18
4
votes
3 answers

How to search the text between the HTML tags

I'm using mongoJS to process my database query. I came across an issue which the string contains HTML tags, I'm using regex expressions to search my string in the collection. How to search the text by ignore the HTML tags? var userInput =…
Abel
  • 1,494
  • 3
  • 21
  • 32
4
votes
2 answers

how exactly to use foreach in nodejs for Mongodb operations

This is my code to get the data from a collection groupname which is initialised with the name of collection. I want to iterate the data stored in doc using foreach loop. var db = mongojs('login'); var cursor = db.collection(groupname).find(); …
sachin hunur
  • 281
  • 2
  • 6
  • 17
4
votes
2 answers

Mongodb text search multiple fields

I have a mongodb document which looks like this: document title suburb id date And I want to add a search feature where people can search for documents via suburb and title. I am using the text search feature and I want something like…
shash7
  • 1,719
  • 1
  • 18
  • 20
4
votes
3 answers

MongoDB won't save JSON document?

Quick question, but does anyone have a clue why MongoDB won't save the following document? I'm using MongoJS in NodeJS to connect to MongoDB and using the following lines of code to save (in my JS file, the function call is underneath the variable…
techalicious
  • 443
  • 1
  • 6
  • 14
4
votes
1 answer

MongoDB combining find with text search

I'm trying to filter a MongoDB collection with a .find() query and run a text search on the results to lower the cost of the query but I can't seem to be able to chain the commands. Here's what I've tried (that doesn't work): db.jobs.find({ …
A.M.K
  • 16,727
  • 4
  • 32
  • 64
3
votes
3 answers

MongoDb: Insert or update multiple documents with a unique index

I have a MongoDB collection with a unique index. I am trying to insert or update an array of documents into that collection. If there is NO existing document in the collection matching the unique index of the document, that new document should be…
etayluz
  • 15,920
  • 23
  • 106
  • 151
3
votes
2 answers

Mongojs.ObjectId() produces wrong timestamp

When create a new ObjectId in my node.js script using: mongojs.ObjectId() I get an _id like “f5818257dd0b55ce321f87b5” When I use: mongojs.ObjectId(“f5818257dd0b55ce321f87b5”).getTimestamp() I get: “Sun Jul 10 2016 19:12:21 GMT+0200…
3
votes
1 answer

MongoError: socket hang up

I am trying to connect to the mongodb database on mongolabs(mlabs). I connect successfully when I run the code on my local computer and server.But When I run on my aws server I get this error database error { [MongoError: socket hang up] name:…
Mohammed Gadiwala
  • 1,923
  • 2
  • 18
  • 26
1
2
3
20 21