Updates
This commit is contained in:
@@ -16,4 +16,4 @@ export default function dsqlMethodCrud<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ method, tableName, addUser, user, extraData, transform, existingData, body, query, targetId, }: DsqlMethodCrudParam<T>): Promise<CRUDResponseObject<P>>;
|
||||
}>({ method, tableName, addUser, user, extraData, transform, existingData, body, query, targetId, sanitize, }: DsqlMethodCrudParam<T>): Promise<CRUDResponseObject<P>>;
|
||||
|
||||
+7
-3
@@ -16,7 +16,7 @@ exports.default = dsqlMethodCrud;
|
||||
const ejson_1 = __importDefault(require("../ejson"));
|
||||
const crud_1 = __importDefault(require("./crud"));
|
||||
function dsqlMethodCrud(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ method, tableName, addUser, user, extraData, transform, existingData, body, query, targetId, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ method, tableName, addUser, user, extraData, transform, existingData, body, query, targetId, sanitize, }) {
|
||||
let result = {
|
||||
success: false,
|
||||
};
|
||||
@@ -44,9 +44,9 @@ function dsqlMethodCrud(_a) {
|
||||
OFFSET = (PAGE - 1) * LIMIT;
|
||||
}
|
||||
let finalData = finalBody
|
||||
? Object.assign(Object.assign({}, finalBody.data), extraData)
|
||||
? Object.assign(Object.assign({}, finalBody), extraData)
|
||||
: undefined;
|
||||
if (finalData && user && addUser) {
|
||||
if (finalData && (user === null || user === void 0 ? void 0 : user.id) && addUser) {
|
||||
finalData = Object.assign(Object.assign({}, finalData), { [addUser.field]: String(user.id) });
|
||||
}
|
||||
if (transform && finalData) {
|
||||
@@ -69,6 +69,7 @@ function dsqlMethodCrud(_a) {
|
||||
}
|
||||
: undefined }), limit: LIMIT, offset: OFFSET || undefined })
|
||||
: undefined,
|
||||
sanitize,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(GET_RESULT === null || GET_RESULT === void 0 ? void 0 : GET_RESULT.success),
|
||||
@@ -82,6 +83,7 @@ function dsqlMethodCrud(_a) {
|
||||
action: "insert",
|
||||
table: tableName,
|
||||
data: finalData,
|
||||
sanitize,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(POST_RESULT === null || POST_RESULT === void 0 ? void 0 : POST_RESULT.success),
|
||||
@@ -96,6 +98,7 @@ function dsqlMethodCrud(_a) {
|
||||
table: tableName,
|
||||
data: finalData,
|
||||
targetId,
|
||||
sanitize,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(PUT_RESULT === null || PUT_RESULT === void 0 ? void 0 : PUT_RESULT.success),
|
||||
@@ -109,6 +112,7 @@ function dsqlMethodCrud(_a) {
|
||||
action: "delete",
|
||||
table: tableName,
|
||||
targetId,
|
||||
sanitize,
|
||||
});
|
||||
result = {
|
||||
success: Boolean(DELETE_RESULT === null || DELETE_RESULT === void 0 ? void 0 : DELETE_RESULT.success),
|
||||
|
||||
Reference in New Issue
Block a user