我不知道为什么它不起作用
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
mongoose.connect(process.env.MONGO_URI);
var userSchema = new Schema({
username: String,
password: String,
books: [{type: Schema.Types.ObjectId, ref: 'User'}]
}
);
var bookSchema = new Schema({
bookid: {type:String, unique:true, required:true},
imgURL: String
});
module.exports.user = mongoose.model('User', userSchema);
module.exports.book = mongoose.model('Book', bookSchema);
答案 0 :(得分:-1)
您的JSON格式不正确。 用这种格式调整
像这样调整你的代码
{ “dataOne”:[{“keyOne”:“valueOne”,“keyTwo”:“valueTwo”},{“keyOne”:“valueOne”,“keyTwo”:“valueTwo”},], “dataTwo”:[{ “keyOne”: “valueOne”},{ “keyOne”: “valueOne”}] }