feat: db tables and repo and service written

This commit is contained in:
2025-01-06 14:05:03 +01:00
parent 62847f569d
commit c2e0fe94a4
9 changed files with 278 additions and 29 deletions

View File

@ -0,0 +1,38 @@
import { injectable } from "tsyringe";
import { WifiLocation } from "../models/wifiLocation";
@injectable()
export class WifiLocationRepository {
public async findAll() {
return await WifiLocation.findAll();
}
public async findById(id: string) {
return await WifiLocation.findByPk(id);
}
public async create(data: Partial<WifiLocation>) {
return await WifiLocation.create(data);
}
public async createMany(data: Partial<WifiLocation>[]) {
return await WifiLocation.bulkCreate(data);
}
public async update(id: string, data: Partial<WifiLocation>) {
const wifiScan = await this.findById(id);
if (wifiScan) {
return await wifiScan.update(data);
}
return null;
}
public async delete(id: string) {
const wifiScan = await this.findById(id);
if (wifiScan) {
await wifiScan.destroy();
return true;
}
return false;
}
}