sepcify not null sqlite to prevent some issues

This commit is contained in:
Amaury 2021-04-18 16:19:38 +02:00
parent 3f2b00eccb
commit 95a10dfc60

View File

@ -15,9 +15,9 @@ export class SqliteTools {
let req = sql`CREATE TABLE IF NOT EXISTS listeners
(
address TEXT NOT NULL UNIQUE,
customfields TEXT DEFAULT '[]',
timeloop INTEGER DEFAULT 300,
last_entries_links TEXT DEFAULT '[]',
customfields TEXT DEFAULT '[]' NOT NULL,
timeloop INTEGER DEFAULT 300 NOT NULL,
last_entries_links TEXT DEFAULT '[]' NOT NULL,
PRIMARY KEY (address),
CHECK(timeloop >= 0)
);`;
@ -47,8 +47,8 @@ export class SqliteTools {
let req = sql`INSERT INTO listeners (address, timeloop, customfields, last_entries_links)
VALUES (${listener.address},
${listener.timeloop},
${JSON.stringify(listener.customfields)},
${JSON.stringify(listener.lastEntriesLinks)})`;
${JSON.stringify(listener.customfields ? listener.customfields : [])},
${JSON.stringify(listener.lastEntriesLinks ? listener.lastEntriesLinks : [])})`;
await db.query(req);
await db.dispose();
}