所有的猫鼬事件是什么,它们在哪里记录? [英] What are all the mongoose events and where are they documented?

查看:81
本文介绍了所有的猫鼬事件是什么,它们在哪里记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以用猫鼬处理各种事件,例如

There are various events I can handle with mongoose, e.g.

mongoose.connection.on("connecting", () => this.onConnecting());

我遇到的一些人

  • 连接
  • 错误
  • 已连接
  • 打开
  • 重新连接
  • 已断开连接

我找不到这些文件的记录位置.我以为它们也许不是mogoose的一部分,而是mongodb本身的一部分,但是我在mongo网站上也找不到它们.

I can't find where these are documented. I thought that maybe they weren't part of mogoose, but rather of mongodb itself, but I couldn't find them on the mongo site either.

在哪里可以找到记录的这些事件(及其他事件)?

Where can I find these events (and others) documented?

推荐答案

您可以在github的源代码中找到它. https://github.com/Automattic/mongoose/blob/master/lib /connection.js

You can find it on github in the source code. https://github.com/Automattic/mongoose/blob/master/lib/connection.js

列出的事件比给定的答案还要多,它们是:

There are many more events listed than the given answer, here they are:

  • @event connecting:在此连接上执行connection.openUri()时发出.
  • @event connected:此连接成功连接到数据库时发出.在reconnected场景中可能被发射多次次.
  • @event open:在所有这些连接模型上执行connectedonOpen后发出.
  • @event disconnecting:在执行connection.close()时发出.
  • @event disconnected:与数据库断开连接后发出.
  • @event close:在所有这些连接模型上执行disconnectedonClose后发出.
  • @event reconnected:在我们connected和随后的disconnected之后发出,然后成功进行另一个成功连接.
  • @event error:在此连接上发生错误时触发.
  • @event fullsetup:在副本集方案中,连接了连接字符串中指定的主服务器和至少一个服务器时,发出此消息.
  • @event all:当连接字符串中指定的所有节点均已连接时,在副本集方案中发出.
  • @event connecting: Emitted when connection.openUri() is executed on this connection.
  • @event connected: Emitted when this connection successfully connects to the db. May be emitted multiple times in reconnected scenarios.
  • @event open: Emitted after we connected and onOpen is executed on all of this connections models.
  • @event disconnecting: Emitted when connection.close() was executed.
  • @event disconnected: Emitted after getting disconnected from the db.
  • @event close: Emitted after we disconnected and onClose executed on all of this connections models.
  • @event reconnected: Emitted after we connected and subsequently disconnected, followed by successfully another successfull connection.
  • @event error: Emitted when an error occurs on this connection.
  • @event fullsetup: Emitted in a replica-set scenario, when primary and at least one seconaries specified in the connection string are connected.
  • @event all: Emitted in a replica-set scenario, when all nodes specified in the connection string are connected.

这篇关于所有的猫鼬事件是什么,它们在哪里记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆