mongodb.open(function (err,collection) {
if(err) {
mongodb.close();
return callback(err);
}
// 这里 collection.insert 方法不存在 我打印了一下 collection 有毛线insert啊
collection.insert(user,{safe:true}, function(err, user) {
mongodb.close();
callback(err, user);
});
/// mongodb 的定义
var settings = require("../settings.js");
var Md = require("mongodb")
var Db = Md.Db;
var Connection = Md.Connection;
var Server = Md.Server;
module.exports = new Db(settings.db, new Server(settings.host, Connection.DEFAULT_PORT,{}));
//// collection打印出来的方法 部分
domain
_events
_maxListeners
databaseName
serverConfig
options
_applicationClosed
slaveOk
bufferMaxEntries
native_parser
bsonLib
bson
bson_deserializer
bson_serializer
_state
pkFactory
forceServerObjectId
safe
notReplied
isInitializing
openCalled
commands
logger
tag
eventHandlers
serializeFunctions
raw
recordQueryStats
retryMiliSeconds
numberOfRetries
readPreference
open
db
close
admin
collectionsInfo
collectionNames
collection
collections
eval
dereference
logout
3 回复