我正在尝试写一个 SailsJS/Waterline适配器 OrientDB使用 Oriento NodeJS 模块。
我能够使用 boilerplate adapter code for SailsJS 了解 Waterline 适配器接口(interface)的基础知识但不确定如何在适配器方法中获取数据库对象。我确信 DB 对象是由 SailsJS 或 Waterline 创建和维护的,但是如何在适配器的方法中访问它,因为没有 DB 对象,我将无法调用 OrientDB。在 Oriento 中查找代码示例模块来了解如何从 NodeJS 调用 OrientDB。
如果有人可以展示一些在适配器的方法中获取数据库对象的示例代码 - Define()、describe()、drop()、find() 等,我将不胜感激。
最佳答案
我们不熟悉 Sails,但看起来 _dbPools
私有(private)变量就是您要找的 - https://github.com/balderdashy/sails-adapter-boilerplate/blob/master/index.js#L59
关于node.js - 如何在 SailsJS/Waterline 适配器方法中获取 DB 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24118191/