MongoDB and Mongoose - Create a Model help me

MongoDB and Mongoose - Create a Model help me
0

#1

const Schema = mongoose.Schema;
const personSchema = new Schema({
name:{type:String,required:true},
age: Number,
favoriteFoods:[String]

});
const Person = mongoose.model(‘Person’, personSchema);

I am a new in mongoose I confused in this problem Please somebody help me


#2

And what is problem? it’s look o.k.
did you have var mongoose = require(‘mongoose’);
http://mongoosejs.com/docs/guide.html
http://mongoosejs.com/docs/schematypes.html


#3

hi,

if you want declare “favoriteFoods” like an array:

favoriteFoods:[]