35 lines
659 B
JavaScript
35 lines
659 B
JavaScript
"use strict";
|
|
|
|
import { get_instance } from '../Helpers/Database.mjs';
|
|
|
|
class ReadingRepo {
|
|
constructor(in_RSSIRepo) {
|
|
this.db = get_instance();
|
|
this.RSSIRepo = in_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,
|
|
: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();
|
|
}
|
|
}
|
|
|
|
export default ReadingRepo;
|