问题
I have been trying to get a query result from Arangodb in to my front end service (Angular 4) using soap message. I am able to get a result of the query but printed out in console.log. But how can I get it under this function (Service).
So that I can feed into the soap message:
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>';
I posted this issue got a response saying to use await or .this(), then I have updated my code but still the error remains.
I have tried to feed in to a random variable with some string like this to check the soap msg.,
var payload = [null,"192.168.72.237"];
it works fine.There is a problem with query
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);
})
The versions are
- "node": "8.9.4"
- "arangojs": "^5.8.0",
- "express": "^4.16.2",
- "express-generator": "^4.15.5"
I don't have a clue to take it forward from here.
回答1:
To have the promise resolve for you, it's necessary to invoke the .all
function of the cursor so that it will return the values.
This site has a good example which is simply:
db.query('FOR doc IN documents RETURN doc')
.then((cursor) => { return cursor.all() })
.then((doc) => { console.log(doc) });
The promise returned by the first step is then invoked to extract the records, and the return from the cursor is the documents you're looking for.
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);
})
来源:https://stackoverflow.com/questions/48966201/how-to-solve-arango-query-promise-error