在 Mongoose ( http://mongoosejs.com/docs/index.html ) 的“入门”中有一个使用函数 once
的示例。 :
db.once('open', function callback () {
// yay!
});
但在官方文档中我没有找到任何对函数
once
的引用( http://mongoosejs.com/docs/api.html )。这个函数的意义是什么?
最佳答案
Mongoose 连接是 EventEmitter class 的一个实例.从文档:
Adds a one time listener for the event. This listener is invoked only the next time the event is fired, after which it is removed.
关于 Mongoose :函数 "once",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17575300/