Skip to content

Instantly share code, notes, and snippets.

@monapasan
Created October 21, 2021 18:38
Show Gist options
  • Save monapasan/ade6750e6a5fc0ce457a852043e28aa5 to your computer and use it in GitHub Desktop.
Save monapasan/ade6750e6a5fc0ce457a852043e28aa5 to your computer and use it in GitHub Desktop.
async function exportContexts(savedContexts) {
// Iterate through every user
for (let user in savedContexts) {
// Iterate through every context of that user
for (let i = 0; i < savedContexts[user].length; i++) {
let contextname = savedContexts[user][i];
// Generate a Cypher statement to return the username, the context name and the statement text
let statement =
"MATCH (u:User{name:'" +
user +
"'})<-[:BY]-(c:Context{name:'" +
contextname +
"'})<-[:IN]-(s:Statement) return u.name as username, c.name as context, s.text as statement;";
// TODO at this point we can also create the user in PostgreSQL
// QUESTION OLEG how to make this cycle continue iterating ONLY if the function below is executed?
await exportStatements(statement);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment