31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { DbContextsArray } from "./runQuery";
|
|
import { APIResponseObject, DSQL_TableSchemaType, PostInsertReturn } from "../../../types";
|
|
export type AddDbEntryParam<T extends {
|
|
[k: string]: any;
|
|
} = any, K extends string = string> = {
|
|
dbContext?: (typeof DbContextsArray)[number];
|
|
paradigm?: "Read Only" | "Full Access";
|
|
dbFullName?: string;
|
|
tableName: K;
|
|
data?: T;
|
|
batchData?: T[];
|
|
tableSchema?: DSQL_TableSchemaType;
|
|
duplicateColumnName?: keyof T;
|
|
duplicateColumnValue?: string | number;
|
|
/**
|
|
* Update Entry if a duplicate is found.
|
|
* Requires `duplicateColumnName` and `duplicateColumnValue` parameters
|
|
*/
|
|
update?: boolean;
|
|
encryptionKey?: string;
|
|
encryptionSalt?: string;
|
|
forceLocal?: boolean;
|
|
debug?: boolean;
|
|
};
|
|
/**
|
|
* Add a db Entry Function
|
|
*/
|
|
export default function addDbEntry<T extends {
|
|
[k: string]: any;
|
|
} = any, K extends string = string>({ dbContext, paradigm, dbFullName, tableName, data, batchData, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, forceLocal, debug, }: AddDbEntryParam<T, K>): Promise<APIResponseObject<PostInsertReturn>>;
|