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) {
|
|
|
|
if(typeof this.query_insert == "undefined")
|
|
|
|
this.query_insert = this.db.prepare(`INSERT INTO rssis (
|
|
|
|
id,
|
2019-07-09 13:07:23 +00:00
|
|
|
reading_id, gateway_id,
|
2019-05-29 10:35:10 +00:00
|
|
|
rssi, snr,
|
|
|
|
channel
|
|
|
|
) VALUES (
|
|
|
|
:id,
|
2019-07-10 11:21:38 +00:00
|
|
|
:reading_id, :gateway_id,
|
2019-05-29 10:35:10 +00:00
|
|
|
:rssi, :snr,
|
|
|
|
:channel
|
|
|
|
)`);
|
|
|
|
|
|
|
|
for(let rssi of rssis)
|
|
|
|
this.insert_query.run(rssi);
|
|
|
|
}
|
|
|
|
|
|
|
|
iterate() {
|
|
|
|
return this.db.prepare(`SELECT * FROM rssis`).iterate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-29 10:36:36 +00:00
|
|
|
export default RSSIRepo;
|