2019-05-22 11:28:57 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-05-22 17:04:46 +00:00
|
|
|
import { get_instance } from '../Helpers/Database.mjs';
|
|
|
|
|
2019-05-22 11:28:57 +00:00
|
|
|
class ReadingRepo {
|
2019-05-22 17:04:46 +00:00
|
|
|
constructor(in_RSSIRepo) {
|
|
|
|
this.db = get_instance();
|
|
|
|
this.RSSIRepo = in_RSSIRepo;
|
2019-05-22 11:28:57 +00:00
|
|
|
|
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,
|
|
|
|
:lat,
|
|
|
|
:long,
|
|
|
|
: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;
|