mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 16:27:46 +00:00
find by id of ormify patch
This commit is contained in:
committed by
Akhil Mohan
parent
6cee8dc7e5
commit
d1597ed8da
@@ -50,11 +50,12 @@ export const ormify = <DbOps extends object, Tname extends keyof Tables>(
|
|||||||
const res = await cb(trx);
|
const res = await cb(trx);
|
||||||
return res;
|
return res;
|
||||||
}),
|
}),
|
||||||
findById: (id: string, tx?: Knex) => {
|
findById: async (id: string, tx?: Knex) => {
|
||||||
try {
|
try {
|
||||||
return (tx || db)(tableName)
|
const result = await (tx || db)(tableName)
|
||||||
.where({ id } as any)
|
.where({ id } as any)
|
||||||
.first("*");
|
.first("*");
|
||||||
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new DatabaseError({ error, name: "Find by id" });
|
throw new DatabaseError({ error, name: "Find by id" });
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,7 @@ export const ormify = <DbOps extends object, Tname extends keyof Tables>(
|
|||||||
const res = await (tx || db)(tableName).where(filter).first("*");
|
const res = await (tx || db)(tableName).where(filter).first("*");
|
||||||
return res;
|
return res;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("I HAVE REACHEd HEREEE===>", tableName)
|
||||||
throw new DatabaseError({ error, name: "Find one" });
|
throw new DatabaseError({ error, name: "Find one" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -83,6 +85,7 @@ export const ormify = <DbOps extends object, Tname extends keyof Tables>(
|
|||||||
const res = await query;
|
const res = await query;
|
||||||
return res;
|
return res;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("I HAVE REACHEd HEREEE===>", tableName)
|
||||||
throw new DatabaseError({ error, name: "Find one" });
|
throw new DatabaseError({ error, name: "Find one" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user