Update types

This commit is contained in:
Benjamin Toby
2024-10-21 08:05:18 +01:00
parent fabf2945d7
commit d774e8d35d
6 changed files with 100 additions and 59 deletions
+40
View File
@@ -315,3 +315,43 @@ export interface GetReturn {
error?: string;
schema?: DSQL_TableSchemaType;
}
interface PostReturn {
success: boolean;
payload?: PostInsertReturn | Object[] | string;
}
interface PostInsertReturn {
fieldCount: number;
affectedRows: number;
insertId: number;
serverStatus: number;
warningCount: number;
message: string;
protocol41: boolean;
changedRows: number;
}
interface PostDataPayload {
action: "insert" | "update" | "delete";
table: string;
data?: object;
identifierColumnName?: string;
identifierValue?: string;
duplicateColumnName?: string;
duplicateColumnValue?: string;
update?: boolean;
}
interface LocalPostReturn {
success: boolean;
payload?: PostInsertReturn | Object[] | string;
msg?: string;
error?: string;
}
interface LocalPostQueryObject {
query: string | import("../../package-shared/types").PostDataPayload;
tableName?: string;
queryValues?: string[];
}
+49
View File
@@ -353,3 +353,52 @@ const http = require("http");
* @property {string} [error] - Error Message
* @property {DSQL_TableSchemaType} [schema] - Error Message
*/
/**
* @typedef {Object} PostReturn
* @property {boolean} success - Did the function run successfully?
* @property { PostInsertReturn | Object[] | string } [payload] - The Y Coordinate
*/
/**
* @typedef {object} PostInsertReturn
* @property {number} fieldCount
* @property {number} affectedRows
* @property {number} insertId
* @property {number} serverStatus
* @property {number} warningCount
* @property {string} message
* @property {boolean} protocol41
* @property {number} changedRows
*/
/**
* @typedef {object} PostDataPayload
* @property {"insert" | "update" | "delete"} action - The target action to take
* @property {string} table - Table name(slug) eg "blog_posts"
* @property {object} [data] - Table insert payload object => This must have keys that match
* table fields
* @property {string?} [identifierColumnName] - Table identifier field name => eg. "id" OR "email"
* @property {string?} [identifierValue] - Corresponding value of the selected field name => This
* checks identifies a the target row for "update" or "delete". Not needed for "insert"
* @property {string?} [duplicateColumnName] - Duplicate column name to check for
* @property {string?} [duplicateColumnValue] - Duplicate column value to match. If no "update" param
* provided, function will return null
* @property {boolean?} [update] - Should the "insert" action update the existing entry if indeed
* the entry with "duplicateColumnValue" exists?
*/
/**
* @typedef {Object} LocalPostReturn
* @property {boolean} success - Did the function run successfully?
* @property { PostInsertReturn | Object[] | string } [payload] - GET request results
* @property {string} [msg] - Message
* @property {string} [error] - Error Message
*/
/**
* @typedef {Object} LocalPostQueryObject
* @property {string | import("../../package-shared/types").PostDataPayload} query - Table Name
* @property {string} [tableName] - Table Name
* @property {string[]} [queryValues] - GET request results
*/