query store CRUD
This commit is contained in:
parent
2518a1046f
commit
7497787ae4
12 changed files with 327 additions and 5 deletions
40
src/service/queryStoreService.ts
Normal file
40
src/service/queryStoreService.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { query } from "../entity/query";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class QueryStoreService {
|
||||
/**
|
||||
* @description get all queryStores
|
||||
* @returns {Promise<Array<query>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<query>> {
|
||||
return await dataSource
|
||||
.getRepository(query)
|
||||
.createQueryBuilder("queryStore")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("queryStores not found", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get queryStore by id
|
||||
* @returns {Promise<query>}
|
||||
*/
|
||||
static async getById(id: number): Promise<query> {
|
||||
return await dataSource
|
||||
.getRepository(query)
|
||||
.createQueryBuilder("queryStore")
|
||||
.where("queryStore.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("queryStore not found by id", err);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue