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

31 lines
505 B
JavaScript

"use strict";
class RSSIRepo {
constructor({ database }) {
this.db = database;
}
add(...rssis) {
const statement = this.db.prepare(`INSERT INTO rssis (
id,
reading_id, gateway_id,
rssi, snr,
channel
) VALUES (
:id,
:reading_id, :gateway_id,
:rssi, :snr,
:channel
)`);
for(let rssi of rssis) {
// console.log(`Storing`, rssi);
statement.run(rssi);
}
}
iterate() {
return this.db.prepare(`SELECT * FROM rssis`).iterate();
}
}
export default RSSIRepo;