Skip to content
Advertisement

Tag: mongodb

assertEqual error on nodeJs

I just started nodejs development. I am testing mongodb driver but repeatedly getting assertEquals has no method. code from sourceRepo Error has no method ‘assertEquals’ How to reolve it? Answer You can use Node’s Assert for this (where it is called equal rather than equal*s*): However, for Unit tests or something similar you should consider using some testing framework. eg.

How do I insert HTML into Mongodb?

I keep getting kicked out of the shell when I try to paste in an HTML text file. How can this be done? Do I first need to use some javascript to encode it or something? Example: EDIT I put only single quotes inside my html and wrapped the whole thing in double-quotes, but still no good. shell error: Answer

Multiple populates – mongoosejs

Just a simple query, for example with a double ref in the model. Schema / Model Query I already tried something like In fact only one of the populates works. So, how do is get two populates working ? Answer You’re already using the correct syntax of: Perhaps the meal ObjectId from the order isn’t in the Meals collection?

When to close MongoDB database connection in Nodejs

Working with Nodejs and MongoDB through Node MongoDB native driver. Need to retrieve some documents, and make modification, then save them right back. This is an example: With asynchronous nature, if the process of updating the document takes longer, then when cursor reaches the end of documents, database connection is closed. Not all updates are saved to the database. If

Getting timestamp from mongodb id

How do I get the timestamp from the MongoDB id? Answer The timestamp is contained in the first 4 bytes of a mongoDB id (see: http://www.mongodb.org/display/DOCS/Object+IDs). So your timestamp is: and

Advertisement