feat: initial setup backend with default routes and db connection
This commit is contained in:
34
server/src/repositories/locationRepository.ts
Normal file
34
server/src/repositories/locationRepository.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { injectable } from "tsyringe";
|
||||
import { Location } from "../models/location";
|
||||
|
||||
@injectable()
|
||||
export class LocationRepository {
|
||||
public async findAll() {
|
||||
return await Location.findAll();
|
||||
}
|
||||
|
||||
public async findById(id: string) {
|
||||
return await Location.findByPk(id);
|
||||
}
|
||||
|
||||
public async create(data: Partial<Location>) {
|
||||
return await Location.create(data);
|
||||
}
|
||||
|
||||
public async update(id: string, data: Partial<Location>) {
|
||||
const location = await this.findById(id);
|
||||
if (location) {
|
||||
return await location.update(data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public async delete(id: string) {
|
||||
const location = await this.findById(id);
|
||||
if (location) {
|
||||
await location.destroy();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
34
server/src/repositories/lpTtnEndDeviceUplinksRepository.ts
Normal file
34
server/src/repositories/lpTtnEndDeviceUplinksRepository.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { injectable } from "tsyringe";
|
||||
import { LpTtnEndDeviceUplinks } from "../models/lpTtnEndDeviceUplinks";
|
||||
|
||||
@injectable()
|
||||
export class LpTtnEndDeviceUplinksRepository {
|
||||
public async findAll() {
|
||||
return await LpTtnEndDeviceUplinks.findAll();
|
||||
}
|
||||
|
||||
public async findById(id: string) {
|
||||
return await LpTtnEndDeviceUplinks.findByPk(id);
|
||||
}
|
||||
|
||||
public async create(data: Partial<LpTtnEndDeviceUplinks>) {
|
||||
return await LpTtnEndDeviceUplinks.create(data);
|
||||
}
|
||||
|
||||
public async update(id: string, data: Partial<LpTtnEndDeviceUplinks>) {
|
||||
const uplink = await this.findById(id);
|
||||
if (uplink) {
|
||||
return await uplink.update(data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public async delete(id: string) {
|
||||
const uplink = await this.findById(id);
|
||||
if (uplink) {
|
||||
await uplink.destroy();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
34
server/src/repositories/ttnGatewayReceptionRepository.ts
Normal file
34
server/src/repositories/ttnGatewayReceptionRepository.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { injectable } from "tsyringe";
|
||||
import { TtnGatewayReception } from "../models/ttnGatewayReception";
|
||||
|
||||
@injectable()
|
||||
export class TtnGatewayReceptionRepository {
|
||||
public async findAll() {
|
||||
return await TtnGatewayReception.findAll();
|
||||
}
|
||||
|
||||
public async findById(id: string) {
|
||||
return await TtnGatewayReception.findByPk(id);
|
||||
}
|
||||
|
||||
public async create(data: Partial<TtnGatewayReception>) {
|
||||
return await TtnGatewayReception.create(data);
|
||||
}
|
||||
|
||||
public async update(id: string, data: Partial<TtnGatewayReception>) {
|
||||
const gatewayReception = await this.findById(id);
|
||||
if (gatewayReception) {
|
||||
return await gatewayReception.update(data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public async delete(id: string) {
|
||||
const gatewayReception = await this.findById(id);
|
||||
if (gatewayReception) {
|
||||
await gatewayReception.destroy();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
34
server/src/repositories/wifiScanRepository.ts
Normal file
34
server/src/repositories/wifiScanRepository.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { injectable } from "tsyringe";
|
||||
import { WifiScan } from "../models/wifiScan";
|
||||
|
||||
@injectable()
|
||||
export class WifiScanRepository {
|
||||
public async findAll() {
|
||||
return await WifiScan.findAll();
|
||||
}
|
||||
|
||||
public async findById(id: string) {
|
||||
return await WifiScan.findByPk(id);
|
||||
}
|
||||
|
||||
public async create(data: Partial<WifiScan>) {
|
||||
return await WifiScan.create(data);
|
||||
}
|
||||
|
||||
public async update(id: string, data: Partial<WifiScan>) {
|
||||
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