2019-05-22 11:28:57 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
class ReadingRepo {
|
2019-07-09 13:05:42 +00:00
|
|
|
constructor({ database, RSSIRepo }) {
|
|
|
|
this.db = database;
|
|
|
|
this.RSSIRepo = RSSIRepo;
|
2019-05-22 17:04:46 +00:00
|
|
|
}
|
|
|
|
|
2019-05-23 21:48:51 +00:00
|
|
|
add(reading) {
|
2019-05-29 10:35:10 +00:00
|
|
|
if(typeof this.query_insert == "undefined")
|
|
|
|
this.query_insert = this.db.prepare(`INSERT INTO readings (
|
|
|
|
id,
|
|
|
|
lat, long,
|
|
|
|
data_rate_id, code_rate, bit_rate
|
|
|
|
) VALUES (
|
|
|
|
:id,
|
2019-07-09 13:05:42 +00:00
|
|
|
:latitude,
|
|
|
|
:longitude,
|
2019-05-29 10:35:10 +00:00
|
|
|
:data_rate_id, :code_rate, :bit_rate
|
|
|
|
)`);
|
|
|
|
|
|
|
|
this.insert_query.run(reading);
|
|
|
|
|
|
|
|
this.RSSIRepo.add(...reading.rssis);
|
|
|
|
}
|
|
|
|
|
|
|
|
iterate() {
|
|
|
|
return this.db.prepare(`SELECT * FROM readings`).iterate();
|
2019-05-22 11:28:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ReadingRepo;
|