7 changed files with 69 additions and 9 deletions
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
{ |
||||
"ecmaVersion": 8, |
||||
"libs": [], |
||||
"loadEagerly": [], |
||||
"dontLoad": [], |
||||
"plugins": { |
||||
"doc_comment": true |
||||
} |
||||
} |
@ -1,16 +1,18 @@
@@ -1,16 +1,18 @@
|
||||
"use strict"; |
||||
|
||||
import Database from 'batter-sqlite3'; |
||||
import fs from 'fs'; |
||||
import Database from 'better-sqlite3'; |
||||
|
||||
var db_connection = null; |
||||
var db = null; |
||||
|
||||
function init(filename, options) { |
||||
db_connection = new Database(filename, options); |
||||
async function init(filename, options) { |
||||
db = new Database(filename, options); |
||||
db.exec(await fs.promises.readFile("../db_template.sql", "utf8")); |
||||
} |
||||
|
||||
function get_connection() { |
||||
return db_connection; |
||||
function get_instance() { |
||||
return db; |
||||
} |
||||
|
||||
|
||||
export { init, get_connection }; |
||||
export { init, get_instance }; |
||||
|
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE readings IF NOT EXISTS ( |
||||
id INTEGER PRIMARY KEY, -- Random unique integer |
||||
lat FLOAT NOT NULL, -- Latitude component of GPS co-ordinates of reading |
||||
long FLOAT NOT NULL, -- Longitude component of GPS co-ordinates of reading, |
||||
data_rate_id INTEGER, -- The id of the data rate code in the data_rates table that describes the data rate at which the message was transmitted |
||||
code_rate TEXT, -- The coding rate at which the message was transmitted. FUTURE: This may need to be an INTEGER field - not sure |
||||
bit_rate INTEGER, -- The bit rate at which the message was transmitted |
||||
); |
||||
CREATE TABLE rssis IF NOT EXISTS ( |
||||
id INTEGER PRIMARY KEY, -- Random unique int |
||||
reading_id INTEGER, -- The id of the object in the readings table that this rssi measurement belongs to |
||||
gateway_id INTEGER, -- Gateway id that the RSSI was from |
||||
rssi FLOAT, -- The RSSI value itself |
||||
channel INTEGER -- The channel that the RSSI was received over. We might be able to use this to detect single-channel gateways |
||||
); |
||||
CREATE TABLE gateways IF NOT EXISTS ( |
||||
id TEXT PRIMARY KEY, -- The gateway s name |
||||
lat FLOAT, -- Latitude component of the claimed GPS co-ordinates of the gateway |
||||
long FLOAT -- Longitude component of the claimed GPS co-ordinates of the gateway |
||||
altitude FLOAT -- Claimed alitude of the gateway |
||||
); |
||||
CREATE TABLE data_rates IF NOT EXISTS ( |
||||
id INTEGER PRIMARY KEY, -- Random unique integer, |
||||
codename TEXT NOT NULL, |
||||
) |
Loading…
Reference in new issue