标签:style blog io ar color os sp 文件 on
在工程的目录中创建settings.js文件(保存数据库的连接信息)
module.exports = { cookieSecret: ‘microblogbyvoid‘, db:‘microblog‘, host:‘localhost‘, }
在models子目录中创建db.js
var settings = require(‘../settings‘); var Db = require(‘mongodb‘).Db; var Connection = require(‘mongodb‘).Connection; var Server = require(‘mongodb‘).Server; module.exports = new Db(settings.db,new Server(settings.host, Connection.DEFAULT_PORT, {}));
标签:style blog io ar color os sp 文件 on
原文地址:http://www.cnblogs.com/xueyuwyz/p/4128718.html