Update CRUD functions type defs
This commit is contained in:
Vendored
+6
-6
@@ -1,16 +1,16 @@
|
||||
import type { APIResponseObject, ServerQueryParam } from "../../types";
|
||||
type Params<T extends {
|
||||
type Params<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}> = {
|
||||
table: string;
|
||||
query?: ServerQueryParam<T>;
|
||||
}, Table extends string = string> = {
|
||||
table: Table;
|
||||
query?: ServerQueryParam<Schema>;
|
||||
targetId?: number | string;
|
||||
};
|
||||
export default function DbDelete<T extends {
|
||||
export default function DbDelete<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>({ table, query, targetId }: Params<T>): Promise<APIResponseObject>;
|
||||
}, Table extends string = string>({ table, query, targetId, }: Params<Schema, Table>): Promise<APIResponseObject>;
|
||||
export {};
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
import DbClient from ".";
|
||||
import _ from "lodash";
|
||||
import sqlGenerator from "../../utils/sql-generator";
|
||||
export default async function DbDelete({ table, query, targetId }) {
|
||||
export default async function DbDelete({ table, query, targetId, }) {
|
||||
try {
|
||||
let finalQuery = query || {};
|
||||
if (targetId) {
|
||||
|
||||
Vendored
+6
-6
@@ -1,15 +1,15 @@
|
||||
import type { APIResponseObject } from "../../types";
|
||||
type Params<T extends {
|
||||
type Params<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}> = {
|
||||
table: string;
|
||||
data: T[];
|
||||
}, Table extends string = string> = {
|
||||
table: Table;
|
||||
data: Schema[];
|
||||
};
|
||||
export default function DbInsert<T extends {
|
||||
export default function DbInsert<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>({ table, data }: Params<T>): Promise<APIResponseObject>;
|
||||
}, Table extends string = string>({ table, data }: Params<Schema, Table>): Promise<APIResponseObject>;
|
||||
export {};
|
||||
|
||||
Vendored
+6
-6
@@ -1,17 +1,17 @@
|
||||
import type { APIResponseObject, ServerQueryParam } from "../../types";
|
||||
type Params<T extends {
|
||||
type Params<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}> = {
|
||||
query?: ServerQueryParam<T>;
|
||||
table: string;
|
||||
}, Table extends string = string> = {
|
||||
query?: ServerQueryParam<Schema>;
|
||||
table: Table;
|
||||
count?: boolean;
|
||||
targetId?: number | string;
|
||||
};
|
||||
export default function DbSelect<T extends {
|
||||
export default function DbSelect<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>({ table, query, count, targetId }: Params<T>): Promise<APIResponseObject<T>>;
|
||||
}, Table extends string = string>({ table, query, count, targetId, }: Params<Schema, Table>): Promise<APIResponseObject<Schema>>;
|
||||
export {};
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ import mysql from "mysql";
|
||||
import DbClient from ".";
|
||||
import _ from "lodash";
|
||||
import sqlGenerator from "../../utils/sql-generator";
|
||||
export default async function DbSelect({ table, query, count, targetId }) {
|
||||
export default async function DbSelect({ table, query, count, targetId, }) {
|
||||
try {
|
||||
let finalQuery = query || {};
|
||||
if (targetId) {
|
||||
|
||||
Vendored
+7
-7
@@ -1,17 +1,17 @@
|
||||
import type { APIResponseObject, ServerQueryParam } from "../../types";
|
||||
type Params<T extends {
|
||||
type Params<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}> = {
|
||||
table: string;
|
||||
data: T;
|
||||
query?: ServerQueryParam<T>;
|
||||
}, Table extends string = string> = {
|
||||
table: Table;
|
||||
data: Schema;
|
||||
query?: ServerQueryParam<Schema>;
|
||||
targetId?: number | string;
|
||||
};
|
||||
export default function DbUpdate<T extends {
|
||||
export default function DbUpdate<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}>({ table, data, query, targetId }: Params<T>): Promise<APIResponseObject>;
|
||||
}, Table extends string = string>({ table, data, query, targetId, }: Params<Schema, Table>): Promise<APIResponseObject>;
|
||||
export {};
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
import DbClient from ".";
|
||||
import _ from "lodash";
|
||||
import sqlGenerator from "../../utils/sql-generator";
|
||||
export default async function DbUpdate({ table, data, query, targetId }) {
|
||||
export default async function DbUpdate({ table, data, query, targetId, }) {
|
||||
try {
|
||||
let finalQuery = query || {};
|
||||
if (targetId) {
|
||||
|
||||
Reference in New Issue
Block a user