Skip to content

Instantly share code, notes, and snippets.

@bbeamer
Created August 5, 2015 15:45
Show Gist options
  • Save bbeamer/5384497e0444f6705ad3 to your computer and use it in GitHub Desktop.
Save bbeamer/5384497e0444f6705ad3 to your computer and use it in GitHub Desktop.
//global variable
var id=[];
//declare a promise to handle this treatement
//would be nice to call the same code many times
//use it as a function
Task.spawn(function* () {
let db = yield Sqlite.openConnection({ path: myPath});
try {
let row = yield db.execute(
"SELECT id FROM 'plates'");
for ( i=0; i < row.length; i++) {
console.log("row["+ i +"] :" + row[i].getResultByIndex(0));
id.push(row[i].getResultByIndex(0));
}
}
finally {
yield db.close();
}
});
console.log("id length:"+id.length);
for (i=0; i<id.length; i++)
console.log(i+" "+id[i]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment