Closed enjoysmath closed 3 years ago
var arangojs = require('arangojs'); const aql = arangojs.aql; const await = arangojs.await; // 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 pokemons = db.collection("testCollection"); async function main() { try { const pokemons = await db.query(aql` FOR pokemon IN ${pokemons} FILTER pokemon.type == "fire" RETURN pokemon `); console.log("My pokemons, let me show you them:"); for await (const pokemon of pokemons) { console.log(pokemon.name); } } catch (err) { console.error(err.message); } } main();
Outputs error: Cannot access 'pokemons' before initialization
Cannot access 'pokemons' before initialization
Oops, thanks for catching this. There are two variables with the same name. I'll fix the documentation.
Outputs error:
Cannot access 'pokemons' before initialization