下面的测试脚本,说我有46个记录:猫鼬说我有46条记录,mongoDB说我有零?
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var DealSchema = new Schema({
title : String,
});
var Deal = mongoose.model('Deal', DealSchema);
mongoose.connect('mongodb://localhost/dealsite');
mongoose.connection.on("open", function(){
console.log("Mongoose connected");
Deal.count({}, function(err, count){
console.log("Records:", count);
})
});
输出:
$ node testmongo.js
Mongoose connected
Records: 46
而如果我尝试使用蒙戈外壳,我得到一个不同的故事来读线:
$ mongo localhost/dealsite
MongoDB shell version: 1.4.4
url: localhost/dealsite
connecting to: localhost/dealsite
type "exit" to exit
type "help" for help
> db.dealsite.count()
0
> db.dealsite.Deal.count()
0
我的记录隐藏在哪里?
啊哈!谢谢。 :) – 2011-05-17 07:56:17