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

33 lines
553 B
JavaScript
Raw Normal View History

"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();
}
}
2019-05-29 10:36:36 +00:00
export default GatewayRepo;