2019-05-29 10:35:10 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
class RSSIRepo {
|
2019-07-09 13:05:42 +00:00
|
|
|
constructor({ database }) {
|
|
|
|
this.db = database;
|
2019-05-29 10:35:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add(...rssis) {
|
2019-07-10 13:32:58 +00:00
|
|
|
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
|
|
|
|
)`);
|
2019-07-10 13:44:52 +00:00
|
|
|
for(let rssi of rssis) {
|
|
|
|
// console.log(`Storing`, rssi);
|
2019-07-10 13:32:58 +00:00
|
|
|
statement.run(rssi);
|
2019-07-10 13:44:52 +00:00
|
|
|
}
|
2019-05-29 10:35:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
iterate() {
|
|
|
|
return this.db.prepare(`SELECT * FROM rssis`).iterate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-29 10:36:36 +00:00
|
|
|
export default RSSIRepo;
|