get data from database with mongoose code example
Example 1: get data from mongodb node js using mongoose
var Schema = mongoose.Schema;
var SomeModelSchema = new Schema({
a_string: String,
a_date: Date
});
var SomeModel = mongoose.model('SomeModel', SomeModelSchema );
Example 2: get data from mongodb node js using mongoose
var query = Athlete.find({ 'sport': 'Tennis' });
query.select('name age');
query.limit(5);
query.sort({ age: -1 });
query.exec(function (err, athletes) {
if (err) return handleError(err);
})