-1
我有以下schema
:貓鼬沒有任何反應,當我嘗試插入
module.exports = function (mongoose) {
var playlist = mongoose.Schema({
title: String,
artist: String,
album: String,
time: Date
});
return mongoose.model('playlist', playlist);
};
然後我有以下代碼:
var PlayListModel = require('./schemas/playlist.schema.js')(mongoose);
musicItem.time = new Date();
mongoose.models.playlist().save(musicItem).then(function (result) {
mongoose.find({title: musicItem.title}, function (err, doc) {
if(!err)
{
console.log(doc);
}
else
{
console.log(err);
}
})
}, function (err) {
console.log(err);
})
但是沒有控制檯消息只有一個沒有錯誤以下警告當我啓動服務器:
`open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
任何人都可以告訴我什麼我做過錯了嗎?
注意,回調的'find'回來了的文檔的數組,而不是一個對象(所以'docs',而不是'doc')和我不t認爲'mongoose'本身有一個'find'方法([PlayListModel does](http://mongoosejs.com/docs/queries.html))。 – Mikey