32 lines
611 B
JavaScript
32 lines
611 B
JavaScript
"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_id, code_rate, bit_rate
|
|
) VALUES (
|
|
:id,
|
|
:latitude,
|
|
:longitude,
|
|
: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();
|
|
}
|
|
}
|
|
|
|
export default ReadingRepo;
|