hopefully someone can help me. I'm using sails and sails-mongo to connect to my Mongo DB replicaSet. This is all done via config in Sails, so I do not actually create the connection using the MongoDB driver myself, Sails and the ORM (Waterline) take care of it all for me.
希望有人可以帮助我。我正在使用sails和sails-mongo连接到我的Mongo DB副本集。这一切都是通过Sails中的配置完成的,所以我实际上并没有自己使用MongoDB驱动程序创建连接,Sails和ORM(Waterline)为我处理这一切。
Mainly for logging purposes, I'd like to be able to log any Mongo events (connect, disconnect, reconnect etc), and ideally, I'd like to be able to do this without having to create a new separate MongoDB connection just for this purpose.
主要用于日志记录,我希望能够记录任何Mongo事件(连接,断开连接,重新连接等),理想情况下,我希望能够这样做,而无需为了创建一个新的单独的MongoDB连接这个目的。
Does anyone know how I can hook into the MongoDB events/callbacks of the connection that Waterline/sails-mongo creates?
有谁知道我如何挂钩Waterline / sails-mongo创建的连接的MongoDB事件/回调?
1 个解决方案
#1
1
This is not possible at that time. The feature has been asked tho.
这在当时是不可能的。该功能已被问到。
You can use .native()
on models to access the mongo collection instance but it only concern queries.
您可以在模型上使用.native()来访问mongo集合实例,但它只涉及查询。
Of course you can use require('mongodb')
directly but you won't have the waterline wrapper on it. it's up to you.
当然你可以直接使用require('mongodb'),但你不会有水线包装。随你便。
#1
1
This is not possible at that time. The feature has been asked tho.
这在当时是不可能的。该功能已被问到。
You can use .native()
on models to access the mongo collection instance but it only concern queries.
您可以在模型上使用.native()来访问mongo集合实例,但它只涉及查询。
Of course you can use require('mongodb')
directly but you won't have the waterline wrapper on it. it's up to you.
当然你可以直接使用require('mongodb'),但你不会有水线包装。随你便。