feat: db tables and repo and service written
This commit is contained in:
38
server/src/repositories/wifiLocationHistoryRepository.ts
Normal file
38
server/src/repositories/wifiLocationHistoryRepository.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { injectable } from "tsyringe";
|
||||
import { WifiLocationHistory } from "../models/wifiLocationHistory";
|
||||
|
||||
@injectable()
|
||||
export class WifiLocationHistoryRepository {
|
||||
public async findAll() {
|
||||
return await WifiLocationHistory.findAll();
|
||||
}
|
||||
|
||||
public async findById(id: string) {
|
||||
return await WifiLocationHistory.findByPk(id);
|
||||
}
|
||||
|
||||
public async create(data: Partial<WifiLocationHistory>) {
|
||||
return await WifiLocationHistory.create(data);
|
||||
}
|
||||
|
||||
public async createMany(data: Partial<WifiLocationHistory>[]) {
|
||||
return await WifiLocationHistory.bulkCreate(data);
|
||||
}
|
||||
|
||||
public async update(id: string, data: Partial<WifiLocationHistory>) {
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user