{"size": 871, "ext": "js", "max_stars_repo_path": "db.js", "max_stars_repo_name": "Vihrogon/whatsupdog-api", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "db.js", "max_issues_repo_name": "Vihrogon/whatsupdog-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "db.js", "max_forks_repo_name": "Vihrogon/whatsupdog-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.3939393939, "max_line_length": 70, "alphanum_fraction": 0.6693455798}
import { DB } from './config.js'
import createSqlWasm from 'node-sql-wasm'

var { Database, Statement } = await createSqlWasm()

const db = await new Database({ dbfile: DB + '.db' })

// From here on, the SQL.js API can be used...
//db.query(`DROP TABLE IF EXISTS accounts`)

db.query(`
    CREATE TABLE IF NOT EXISTS accounts (
    email TEXT PRIMARY KEY,
    name TEXT)
  `)

//db.query(`CREATE UNIQUE INDEX IF NOT EXISTS id ON accounts (email)`)
//console.log(db.query(`SELECT email, name FROM accounts`))

export const insert = db.prepare(`
    INSERT INTO accounts
    VALUES ('email2','name2')
  `)
export const prep = db.prepare(`SELECT email FROM accounts`)

export function allEmails() {
  /* for (const email of db.exec(`SELECT email FROM accounts`)) {
    console.log('for', email)
  } */
  prep.bind()
  while (prep.step()) console.log('while', prep.get())
}
