Skip to content

Instantly share code, notes, and snippets.

@jgengo
Last active March 20, 2021 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgengo/c2cc68660c5cade3df0ca7e9f91d765f to your computer and use it in GitHub Desktop.
Save jgengo/c2cc68660c5cade3df0ca7e9f91d765f to your computer and use it in GitHub Desktop.
database.js file
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./database.db', [sqlite3.OPEN_CREATE, sqlite3.OPEN_READWRITE], (err) => {
if (err) console.error(err.message)
});
db.run(`create table if not exists users (id text, name text)`)
db.run(`
create table if not exists logs(
id integer primary key,
author_id text,
recipient_id text,
words_count integer default 0,
chars_count integer default 0,
created_at text not null default (datetime('now','localtime'))
);
`)
module.exports = db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment