Skip to content

Pokemon example doesn't work (pokemons not initialized) #715

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
enjoysmath opened this issue Jan 4, 2021 · 1 comment
Closed

Pokemon example doesn't work (pokemons not initialized) #715

enjoysmath opened this issue Jan 4, 2021 · 1 comment
Assignees
Labels
Documentation Issue concerns missing or incorrect documentation.

Comments

@enjoysmath
Copy link

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

@pluma
Copy link
Contributor

pluma commented Jan 13, 2021

Oops, thanks for catching this. There are two variables with the same name. I'll fix the documentation.

@pluma pluma added the Documentation Issue concerns missing or incorrect documentation. label Jan 13, 2021
@pluma pluma self-assigned this Jan 13, 2021
@pluma pluma closed this as completed in bd2bc20 Mar 12, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Documentation Issue concerns missing or incorrect documentation.
Projects
None yet
Development

No branches or pull requests

2 participants