-
-
Save freaktechnik/8902495eaacc7d406c0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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* () { | |
//global variable | |
let id=[]; | |
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(); | |
} | |
//Do whatever it is after the results are in. | |
console.log("id length:"+id.length); | |
id.forEach((idi, i) => console.log(i, idi)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//declare a promise to handle this treatement | |
//would be nice to call the same code many times | |
//use it as a function | |
let getIds = Task.async(function* () { | |
//global variable | |
let id=[]; | |
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(); | |
} | |
return id; | |
}); | |
let printIds = function(id) { | |
//Do whatever it is after the results are in. | |
console.log("id length:"+id.length); | |
id.forEach((idi, i) => console.log(i, idi)); | |
}; | |
getIds().then(printIds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment