蒙戈:
> db.version()
3.0.8
npm&节点:
npm info using npm@3.3.6
npm info using node@v5.0.0
配置文件:
config.mongodb = {
host: '127.0.0.1',
port: '27017',
db: 'mytest',
monk: {
'auto_reconnect': true,
'poolSize': 5
}
};
我的主要档案:
var config = require('./config');
var monk = require('monk');
var db = monk(config.mongodb.url, config.mongodb.monk);
var languages = db.get('languages');
languages.insert({
a: 'b'
}, function (err, doc) {
if (err) throw err;
console.log('doc: ' + JSON.stringify(doc));
});
的package.json:
{
"name": "instanty",
"version": "0.1.1",
"description": "",
"dependencies": {
"co": "^4.6.0",
"co-monk": "^1.0.0",
"cookie-parser": "^1.4.0",
"forever": "^0.15.1",
"geoip-lite": "^1.1.6",
"handlebars": "^4.0.5",
"jsonwebtoken": "^5.4.1",
"jwt-simple": "^0.4.0",
"koa": "^1.1.2",
"koa-better-ratelimit": "^2.1.2",
"koa-bodyparser": "^2.0.1",
"koa-conditional-get": "^1.0.3",
"koa-generic-session": "^1.10.0",
"koa-handlebars": "^0.5.7",
"koa-mount": "^1.3.0",
"koa-passport": "^2.0.1",
"koa-redis": "^1.0.1",
"koa-router": "^5.3.0",
"koa-static": "^1.5.2",
"lodash": "^3.10.1",
"mongodb": "^2.0.45",
"mongoskin": "^2.0.0",
"monk": "^1.0.1",
"monk": "https://github.com/vccabral/monk.git",
"nodemon": "^1.8.1",
"passport": "^0.3.2",
"passport-http-bearer": "^1.0.1",
"passport-local": "^1.0.0",
"socket.io": "^1.3.7",
"socketio-jwt": "^4.3.3"
},
"devDependencies": {
"del": "2.1.0",
"gulp": "3.9.0",
"gulp-autoprefixer": "3.1.0",
"gulp-concat": "2.6.0",
"gulp-concat-css": "2.2.0",
"gulp-imagemin": "2.4.0",
"gulp-less": "3.0.5",
"gulp-minify-css": "1.2.2",
"gulp-notify": "2.2.0",
"gulp-uglify": "1.5.1",
"imagemin-pngquant": "4.2.0",
"run-sequence": "1.1.5"
},
"main": "app.js",
"scripts": {
"start": "node --harmony app.js"
},
"author": "",
"license": "ISC"
}
我得到了#doc; doc:undefined"。有什么我想念的吗?我的mongodb正在运行。
答案 0 :(得分:0)
您有两个monk
个依赖项:
"monk": "^1.0.1",
"monk": "https://github.com/vccabral/monk.git",
后者给了我相同的结果(doc
未定义),所以我建议删除它并坚持发布到NPM存储库(monk@1.0.1
)。