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

29 lines
511 B
JavaScript

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