When trying to create a library with following JS code:
function advisequery() {
|
var iter = advise select airportname from `travel-sample` where city = 'Grenoble';
|
let acc = [];
|
for (const row of iter) {
|
acc.push(row.advice.adviseinfo.recommended_indexes);
|
}
|
return {'num_entries': acc.length, 'data': acc};
|
}
|
we get error:
Error while compiling library. Cause:
|
compilation failed:
|
Exception: SyntaxError: Unexpected identifier
|
Location: functions/n1ql.js:1
|
Code: function advisequery() { var iter = advise N1QL('select airportname from `travel-sample` where city \u003D \'Grenoble\';', {}); let acc = []; for (const row of iter) { acc.push(row.advice.adviseinfo.recommended_indexes); } return {'num_entries': acc.length, 'data': acc};}
|
SyntaxError: Unexpected identifier
|
Workaround right now it explicitly wrap query with N1QL e.g.
var iter = N1QL("advise select airportname from `travel-sample` where city = 'Grenoble'", {});
|