LoRaWAN-Signal-Mapping/server/Repos.SQLite/ReadingRepo.mjs

33 lines
584 B
JavaScript
Raw Normal View History

"use strict";
class ReadingRepo {
constructor({ database, RSSIRepo }) {
this.db = database;
this.RSSIRepo = RSSIRepo;
}
add(reading) {
if(typeof this.query_insert == "undefined")
this.query_insert = this.db.prepare(`INSERT INTO readings (
id,
lat, long,
data_rate, code_rate
) VALUES (
:id,
:latitude,
:longitude,
:data_rate, :code_rate
)`);
this.insert_query.run(reading);
this.RSSIRepo.add(...reading.rssis);
}
iterate() {
return this.db.prepare(`SELECT * FROM readings`).iterate();
}
}
export default ReadingRepo;