标签:new sch mongo error ring logs cti div class
简介
var mongoose = require(‘mongoose‘) mongoose.connect(‘mongodb://123.206.112.122:27017/blog‘) var db = mongoose.connection; db.on(‘error‘, console.error.bind(console, ‘connection error:‘)); db.once(‘open‘, function() { console.log(‘hehe‘) var essaySchema = mongoose.Schema({ id:Number, title:String, content:String }) essaySchema.methods.log = function(){ console.log(this.title) } var Essay = mongoose.model(‘Essay‘,essaySchema) var essay1 = new Essay({id:1,title:‘essay title‘,content:‘1‘}) essay1.save(function(err,essay1){ if(err) return console.error(err); essay1.log() }) });
标签:new sch mongo error ring logs cti div class
原文地址:http://www.cnblogs.com/heinz-lxy/p/6661789.html