I did these two models and i have no idea how to make connection between food and user.
model 1:
const mongoose = require('mongoose');
const passportLocalMongoose = require('passport-local-mongoose');
var UserSchema = new mongoose.Schema({
username: String,
password: String,
repassword: String,
email: String
})
UserSchema.plugin(passportLocalMongoose);
module.exports = mongoose.model("User", UserSchema);
model 2:
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);