0
我有这个集合名称的一个问题:的MongoDB Node.js的
module.exports = function() {
var mongoose = require('mongoose');
var db = mongoose.createConnection('localhost', 'race');
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {});
var collection = 'test';
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
var schema = new Schema({
author: ObjectId,
name: String,
date: Date
});
this.model = db.model(collection, schema);
var silence = new this.model({ name: 'Silence' })
console.log(silence.name);
silence.save();
this.model.find(function (err, log) {
console.log(err)
console.log(log)
})
return this;
};
我已经有一个测试集,但执行console.log(日志)只返回沉默,
其实沉默是登记“测试”的收集和没有“测试”
你能解释一下我为什么,我设置
var collection = 'test';
It works thanks :) – Ajouve