LoRaWAN-Signal-Mapping/server/Repos.SQLite/GatewayRepo.mjs

32 lines
553 B
JavaScript

"use strict";
import { get_instance } from '../Helpers/Database.mjs';
class GatewayRepo {
constructor() {
this.db = get_instance();
}
add(...gateways) {
if(typeof this.query_insert == "undefined")
this.query_insert = this.db.prepare(`INSERT INTO gateways (
id,
lat, long,
altitude
) VALUES (
:id,
:lat, :long,
:altitude
)`);
for(let gateway of gateways)
this.insert_query.run(gateway);
}
iterate() {
return this.db.prepare(`SELECT * FROM gateways`).iterate();
}
}
export default GatewayRepo;