I have this model:
var userschema = new mongoose.Schema({
user: String,
imagen: [{
title: String,
author: String,
index: Number,
date: { type: Date, default: Date.now },
comments: [{
user: String,
body: String,
date: { type: Date, default: Date.now }
}]
}],
});
I know how to set, for example,the author of the image, but I don't know how to search the date of an specified image.
And, If I want to search the images of multiple users, how can I show those images in chronologic order, as the Twitter's time line. I use EJS as template, and Express.js in the server-side, how can I do that image-timeline? I don't even know how to acces to an specified image date, so, I'm a really beginner with mongoose.
You're storing dates with the "time" component so if you want to retrieve data for a specific day you have to set an interval for the whole day:
var query = userschema.find(
{"imagen.date": {"$gte": new Date(2013, 1, 7), "$lt": new Date(2013, 1, 8)}});
query.sort({"imagen.date":1}).exec(callback);