arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
601 stars 107 forks source link

`aql` string prefix doesn't work #714

Closed enjoysmath closed 3 years ago

enjoysmath commented 3 years ago
var arangojs = require('arangojs');

// Const variables for connecting to ArangoDB database
const host = '127.0.0.1'
const port = '8529'
const username = 'root'
const password = 'lunamoona'
const databasename = 'testDB'

 // Connection to ArangoDB
db = new arangojs.Database({
    url: `http://${host}:${port}`,
    databaseName: databasename,
    precaptureStackTraces: true,
});

db.useBasicAuth(username, password);

const filterValue = 23;
const mydata = db.collection('testCollection');
const result = db._query(aql`
  FOR d IN ${mydata}
  FILTER d.num > ${filterValue}
  RETURN d
`).toArray();

Outputs the error:


[Running] node "c:\Users\FruitfulApproach\Desktop\Quiver\quiver\src\database_test1.js"
c:\Users\FruitfulApproach\Desktop\Quiver\quiver\src\database_test1.js:21
const result = db._query(aql`
                  ^

ReferenceError: aql is not defined
    at Object.<anonymous> (c:\Users\FruitfulApproach\Desktop\Quiver\quiver\src\database_test1.js:21:19)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

[Done] exited with code=1 in 0.192 seconds
enjoysmath commented 3 years ago

const aql = arangojs.aql;