What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-29 06:50:07
auto increment in mongoose + nodejs
... var bookSchema = new Schema({ author: { type: Schema.Types.ObjectId, ref: 'Author' }, title: String, genre: String, publishDate: Date }); bookSchema.plugin(autoIncrement.plugin, 'Book'); var Book = connection.model('Book', bookSchema)... Add solution -
Javascript 2021-10-25 19:36:10
mongoose reference another model
var mongoose = require('mongoose') , Schema = mongoose.Schema var eventSchema = Schema({ title : String, location : String, startDate : Date, endDate : Date }); var personSchema = Schema({ firstname: String, lastname: St... Add solution -
Javascript 2021-09-01 01:33:02
mongoose query foreign key
const mongoose = require('mongoose'); const personSchema = mongoose.Schema({ _id: Schema.Types.ObjectId, name: String, age: Number, stories: [{ type: Schema.Types.ObjectId, ref: 'Story' }] }); const storySchema = mongoose.Schema({ author: { ty... Add solution