Updates
This commit is contained in:
parent
181501296a
commit
fe2b34d0ee
1
dist/package-shared/types/index.d.ts
vendored
1
dist/package-shared/types/index.d.ts
vendored
@ -1351,6 +1351,7 @@ export type DsqlCrudParam<T extends {
|
|||||||
table: string;
|
table: string;
|
||||||
data?: T;
|
data?: T;
|
||||||
targetId?: string | number;
|
targetId?: string | number;
|
||||||
|
targetValue?: string | number;
|
||||||
targetField?: string;
|
targetField?: string;
|
||||||
query?: DsqlCrudQueryObject<T>;
|
query?: DsqlCrudQueryObject<T>;
|
||||||
sanitize?: (data?: T) => T;
|
sanitize?: (data?: T) => T;
|
||||||
|
@ -4,6 +4,6 @@ export default function dsqlCrud<T extends {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} = {
|
} = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}>({ action, data, table, targetId, query, sanitize, debug, targetField, }: DsqlCrudParam<T>): Promise<(PostReturn & {
|
}>({ action, data, table, targetValue, query, sanitize, debug, targetField, targetId, }: DsqlCrudParam<T>): Promise<(PostReturn & {
|
||||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||||
}) | null>;
|
}) | null>;
|
||||||
|
@ -17,9 +17,8 @@ const get_1 = __importDefault(require("../../actions/get"));
|
|||||||
const post_1 = __importDefault(require("../../actions/post"));
|
const post_1 = __importDefault(require("../../actions/post"));
|
||||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||||
function dsqlCrud(_a) {
|
function dsqlCrud(_a) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetId, query, sanitize, debug, targetField, }) {
|
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetValue, query, sanitize, debug, targetField, targetId, }) {
|
||||||
const finalData = sanitize ? sanitize(data) : data;
|
const finalData = sanitize ? sanitize(data) : data;
|
||||||
const finalId = targetId;
|
|
||||||
let queryObject;
|
let queryObject;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "get":
|
case "get":
|
||||||
@ -50,7 +49,7 @@ function dsqlCrud(_a) {
|
|||||||
action: "update",
|
action: "update",
|
||||||
table,
|
table,
|
||||||
identifierColumnName: targetField || "id",
|
identifierColumnName: targetField || "id",
|
||||||
identifierValue: String(finalId),
|
identifierValue: String(targetValue || targetId),
|
||||||
data: finalData,
|
data: finalData,
|
||||||
},
|
},
|
||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
@ -61,7 +60,7 @@ function dsqlCrud(_a) {
|
|||||||
action: "delete",
|
action: "delete",
|
||||||
table,
|
table,
|
||||||
identifierColumnName: targetField || "id",
|
identifierColumnName: targetField || "id",
|
||||||
identifierValue: String(finalId),
|
identifierValue: String(targetValue || targetId),
|
||||||
},
|
},
|
||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
});
|
});
|
||||||
|
@ -1521,6 +1521,7 @@ export type DsqlCrudParam<
|
|||||||
table: string;
|
table: string;
|
||||||
data?: T;
|
data?: T;
|
||||||
targetId?: string | number;
|
targetId?: string | number;
|
||||||
|
targetValue?: string | number;
|
||||||
targetField?: string;
|
targetField?: string;
|
||||||
query?: DsqlCrudQueryObject<T>;
|
query?: DsqlCrudQueryObject<T>;
|
||||||
sanitize?: (data?: T) => T;
|
sanitize?: (data?: T) => T;
|
||||||
|
@ -9,11 +9,12 @@ export default async function dsqlCrud<
|
|||||||
action,
|
action,
|
||||||
data,
|
data,
|
||||||
table,
|
table,
|
||||||
targetId,
|
targetValue,
|
||||||
query,
|
query,
|
||||||
sanitize,
|
sanitize,
|
||||||
debug,
|
debug,
|
||||||
targetField,
|
targetField,
|
||||||
|
targetId,
|
||||||
}: DsqlCrudParam<T>): Promise<
|
}: DsqlCrudParam<T>): Promise<
|
||||||
| (PostReturn & {
|
| (PostReturn & {
|
||||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||||
@ -21,7 +22,6 @@ export default async function dsqlCrud<
|
|||||||
| null
|
| null
|
||||||
> {
|
> {
|
||||||
const finalData = sanitize ? sanitize(data) : data;
|
const finalData = sanitize ? sanitize(data) : data;
|
||||||
const finalId = targetId;
|
|
||||||
let queryObject: ReturnType<Awaited<typeof sqlGenerator>> | undefined;
|
let queryObject: ReturnType<Awaited<typeof sqlGenerator>> | undefined;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -58,7 +58,7 @@ export default async function dsqlCrud<
|
|||||||
action: "update",
|
action: "update",
|
||||||
table,
|
table,
|
||||||
identifierColumnName: targetField || "id",
|
identifierColumnName: targetField || "id",
|
||||||
identifierValue: String(finalId),
|
identifierValue: String(targetValue || targetId),
|
||||||
data: finalData,
|
data: finalData,
|
||||||
},
|
},
|
||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
@ -70,7 +70,7 @@ export default async function dsqlCrud<
|
|||||||
action: "delete",
|
action: "delete",
|
||||||
table,
|
table,
|
||||||
identifierColumnName: targetField || "id",
|
identifierColumnName: targetField || "id",
|
||||||
identifierValue: String(finalId),
|
identifierValue: String(targetValue || targetId),
|
||||||
},
|
},
|
||||||
forceLocal: true,
|
forceLocal: true,
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "4.5.5",
|
"version": "4.5.6",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user