node.js - Querying mongoose collection -
i'm trying understand collection , how can define several schemas 1 collection , query it.
for example, want define 2 different schemas collection "animals".
var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/test'); var mongoose = require('mongoose'), schema = mongoose.schema; var cat= new schema({ name: string }); module.exports = mongoose.model('cat', cat, 'animals');
and one
var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/test'); var mongoose = require('mongoose'), schema = mongoose.schema; var dog= new schema({ friendliness: boolean }); module.exports = mongoose.model('dog', dog, 'animals');
so how can posts "animal" collection?
upd: i'm sorry if didn't explain question well. updating reply @laggingreflex:
i'm asking searching through collection 2 schemas. can see same question in comments use more 1 schema per collection on mongodb - "any suggestion how methods searching object of both schemas? example, want find both users , registered users , sort date, using query." that's i'm asking. ;)
thanks.
node.js mongodb mongoose
No comments:
Post a Comment