var wrap = require('co-monk');
var monk = require('monk');
var db = monk(config.mongodb.url, config.mongodb.monk);
var sessions = wrap(db.get('sessions'));
var docId =
yield new Promise(function (resolve, reject) {
sessions.col.insert({
title: data.title,
views: 1,
messages: [{
author: new ObjectId(socket._id),
created: new Date(),
message: data.message
}]
}, function (err, doc) {
if (err === null)
resolve(doc[0]._id);
reject(err);
});
});
所以我的问题是,为什么数据库在只插入一个文档时返回一个数组?