- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在我的项目中使用 arangojs 3.4.2。从 3.0 开始,驱动程序不再使用任何 promise 。在尝试了几个库来 promise 驱动程序后,我没有成功(bluebird,promisify-node...):每次驱动程序返回一个新实例时,该实例都不会被 promise ,并且我必须再次 promise 新实例才能与 promise 一起使用:
var Promise=require('bluebird');
var arango=require('arangojs');
db=Promise.promisifyAll(new arango("http://localhost:8529"));
/*db is promisified properly*/
testdb=db.databaseAsync('test').then(function(testInstance){
/*
the testInstance returned by the driver is not promisified
to use it with promises i've to promisify again
*/
})
有办法实现吗?
最佳答案
这是正确的。
如果你想promisify驱动程序中所有对象的所有方法,你需要直接promisify原型(prototype)的方法:
var Database = require('arangojs/lib/Database');
Promise.promisifyAll(Database.prototype);
var db = new Database('http://localhost:8529');
db.databasesAsync().then(function (databases) {
databases.forEach(function (database) {
assertTrue(typeof database.databaseAsync === 'function');
});
});
关于javascript - 有没有正确的方法来 promisify arangojs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29557522/
我想在我的项目中使用 arangojs 3.4.2。从 3.0 开始,驱动程序不再使用任何 promise 。在尝试了几个库来 promise 驱动程序后,我没有成功(bluebird,promisi
我在使用 ArangoJS 库发送参数时遇到问题,想知道是否有人可以提供帮助。 在下面的示例中,如果参数值在查询中,则可以执行 db.query,但是一旦我尝试使用bindVars,我就会收到静默错误
我正在尝试在 Node JS 上使用 ArangoJS 驱动器,当我将以下代码添加到主 app.js 文件时,它可以工作,但是当添加到不同文件中的类中的函数时,它会抛出错误。 Database is
我正在使用 nodejs 应用程序中最新版本的 ArangoDb 和 ArangoJs。我有以下两个顶点 用户 代币 tokens顶点包含向 users 中的用户之一发行的安全 token 。顶点。我
我正在尝试使用 Firebase 云函数来托管与 Arango 数据库通信的 API。 我使用 arangojs 进行连接,但当我尝试访问数据库时出现以下错误。 我尝试使用 IP 地址和 url(指向
我创建了自己的证书颁发机构来为我的开发环境生成 TLSv1.2 证书。我的 CA 有一个根证书、一个由根签名的中间证书和一些由中间证书签名的“叶”证书。我使用其中一个叶证书安全地连接到 arangod
我正在使用 Angular2 和 Typescript (v1.8.10) 开发一个项目。我们希望将 ArangoDB 数据库中的数据集成到 Web 应用程序中。如果可能的话,我想使用 arangoj
我想使用 NodeJS 从 MySQL 数据库读取 60k 记录并将其写入 ArangoDB 数据库。稍后我将使用 ArangoDB 的聚合功能等来处理我的数据集。 来自 PHP,其中脚本通常同步运行
我已经使用 arangojs 几个月了,最近我的一些代码开始失败,而这些代码曾经可以正常工作,关于在使用模板字符串和 aqlQuery 时将变量用作集合名称。 我在 Windows 10 上使用 No
我正在构建一个基于 d3 力导向图并在后端使用 ArangoDB 的应用程序,我希望能够尽可能高效地从 Arango 动态加载节点和链接数据。 我不是 d3 方面的专家,但总的来说力布局似乎希望将其数
我是一名优秀的程序员,十分优秀!