我一直在尝试使用肥皂消息从 Arangodb 获取查询结果到我的前端服务(Angular 4)。我能够获得查询结果,但在 console.log 中打印出来。但是我如何在这个功能(Service)下获取它。
这样我就可以输入肥皂消息:
var soap_msg = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:CheckUserNameService">' +
'<soapenv:Header/>' +
'<soapenv:Body>' +
'<urn:CheckUserNameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
'<status xsi:type="xsd:string">' + (Service) + '</status>' +
'</urn:CheckUserNameResponse>' +
'</soapenv:Body>' +
'</soapenv:Envelope>';
我发布这个问题得到了回复说要使用等待或.this(),然后我更新了我的代码,但错误仍然存在。
我尝试用这样的字符串输入随机变量来检查肥皂消息,
var payload = [null,"192.168.72.237"];
工作正常。查询有问题
var Service = db.query(aqlQuery `
LET startVertex = (FOR doc IN spec
FILTER doc.serial_no == '"123456abcde"'
LIMIT 2
RETURN doc
)[0]
FOR v IN 1 ANY startVertex belongs_to
RETURN v.ip`, {
bindVar1: 'value',
bindVar2: 'value',
}).then(function(res) {
console.log("doc" + res._result);
})
版本是
- “节点”:“8.9.4”
- "arangojs": "^5.8.0",
- "express": "^4.16.2",
- "express-generator": "^4.15.5"
我没有任何线索可以从这里继续下去。
为了让您的承诺得到解决,有必要调用.all
游标的功能,以便它将返回值。
这个网站 https://mikewilliamson.wordpress.com/2015/10/22/a-quick-tour-of-arangojs/有一个很好的例子,很简单:
db.query('FOR doc IN documents RETURN doc')
.then((cursor) => { return cursor.all() })
.then((doc) => { console.log(doc) });
然后调用第一步返回的 Promise 来提取记录,游标返回的就是您要查找的文档。
e.g.
var Service = db.query(aqlQuery `
LET startVertex = (FOR doc IN spec
FILTER doc.serial_no == '"123456abcde"'
LIMIT 2
RETURN doc
)[0]
FOR v IN 1 ANY startVertex belongs_to
RETURN v.ip`, {
bindVar1: 'value',
bindVar2: 'value',
}).then(function(cursor) { // Add this to return the documents in the promise
return cursor.all()
}).then(function(res) {
console.log("doc" + res._result);
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)