Reputation: 3009
mY model,
var CategorySchema = new Schema({
categoryname: {
type: String
},
topictitle: {
type: String
},
topicdescription: {
type: String
},
tag: {
type: String
},
topicid: {
type: Schema.ObjectId
},
user: {
type: Schema.ObjectId,
ref: 'User'
}
});
mongoose.model('topics', CategorySchema);
Here topics is the name of my model but where can i keep my collection name?Can anyone suggest me help.
Upvotes: 0
Views: 1267
Reputation: 2996
In the below model definition
mongoose.model('topics', CategorySchema);
var topics = mongoose.model('topics', CategorySchema,'topics' );
var tags = mongoose.model('tags', TagSchema, 'topics');
'topics' (last parameter) is the collection name & CategorySchema is the structure of a particular document
Check Mongoose documentation
Upvotes: 4