Closed jcuenod closed 4 years ago
Yeah, agreed. Any comments on the below version?
import { open, save } from "https://deno.land/x/sqlite/mod.ts";
// Open a database
const db = await open("test.db");
db.query("CREATE TABLE IF NOT EXISTS people (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");
const names = ["Peter Parker", "Clark Kent", "Bruce Wayne"];
// Run a simple query
for (const name of names)
db.query("INSERT INTO people (name) VALUES (?)", [name]);
// Print out data in table
for (const [name] of db.query("SELECT name FROM people"))
console.log(name);
// Save and close connection
await save(db);
db.close();
Ja, this is great!
I was recently talking about
deno
to someone who said it wasn't accessible to newcomers. I thought about this when I saw this in the example:I realise that this makes the demo more interesting but I think it may detract from communicating clearly how the library works.
Forgive the backstory and obviously it's up to you what to do but I think "hard" hard-coding
name
would make the example more clear.