I have a collection like this:
{
'datetime': some-date,
'lat': '32.00',
'lon': '74.00'
},
{
'datetime': some-date,
'lat': '32.00',
'lon': '74.00'
}
How can I get the latest record from MongoDB, where the datetime is the…
Major Questions
Currently I'm very confused, the main questions are: What is the use of Mongoose/Mongojs? What would be different if I run Node.js without Mongoose/Mongojs?
I can't find any good explanation of the big picture of how Mongoose or…
I have been having trouble inserting an actual datetime object in mongodb using the mongojs driver for nodejs. Any help?
var currentdate = new Date();
var datetime = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+…
I have a document "owner" that can have "n" number of camps and camps have "instructors" and instructors have "classes". Earlier I tried accomplishing this with nested arrays (see link to my post below), however I learned that the positional…
I am getting error "TypeError: Cannot read property '_id' of undefined" on a simple post request to save a document to the collection called books,
My payload looks like this:
{
"name": "practical view",
"author": "DN",
"location": "room…
Hi I am trying to use the Async module to retrieve two users and do some processing after they have both been retrieved however I keep getting the error message: Callback was already called. Below is the code i currently…
I've run into a situation where I need to dynamically update the value of a field in a subdocument. The field may or may not already exist. If it doesn't exist, I'd like mongo to create it.
Here's an example document that would be found in my Teams…
I'm using mongojs and I'm trying to iterate over all elements in a collection
index = 0
db.keys.find({}, {uid: 1, _id: 0}).forEach((err, key) =>
if err?
console.log err
else
console.log (++index) + " key: " + key_uid
which…
I'm writing an application where I use express, Node.js and MongoDB (using mongojs). I have a module db.js and a server.js, which have the snippets below.
db.js
var getUsersByCity = function(city, callback) {
db.users.find({'city':…
Does anyone have a good approach for a query against a collection for documents that are older than 30 seconds. I'm creating a cleanup worker that marks items as failed after they have been in a specific state for more than 30 seconds.
Not that it…
I'm new with nodeJS and MongoDB.
I have this code:
var fs = require('fs');
var mongojs = require('mongojs');
var db = mongojs('monitor', ["configurations"]);
fs.readFile('json/object1.json', 'utf8', function (err, data) {
if (err) throw err;
…
I would like to be able to query my mongoDB and display this result on my web page made with Node...right now I am using the mongojs driver - I've found the driver very very good for putting data into the DB - the syntax is the same as the Mongo…
I've got the following doc in my db:
{
"_id": ObjectId("ABCDEFG12345"),
"options" : {
"foo": "bar",
"another": "something"
},
"date" : {
"created": 1234567890,
"updated": 0
}
}
And I want to update options.foo and…
Using NodeJS + MongoJS, I have connection to a mongo DB.
I set a TTL on a collection with:
myCollection.createIndex({createdAt: 1}, {expireAfterSeconds: 60 * 30})
Is it now possible to update the value for expireAfterSeconds ?
If so, what's the…