Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to connect two model in mongoose

var mongoose = require('mongoose');


var foodSchema = new mongoose.Schema({
   name: String,
   image: String,
   notify: String,
   createdAt: {type: Date, default: Date.now},
    author: {
      id: {
         type: mongoose.Schema.Types.ObjectId,
         ref: "User"
      },
      username: String
   },
});


   module.exports = mongoose.model("food", foodSchema);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #connect #model #mongoose
ADD COMMENT
Topic
Name
9+5 =