Updates
This commit is contained in:
parent
fcc668d3a1
commit
3597b11342
@ -13,6 +13,7 @@ type Param<T extends {
|
|||||||
identifierColumnName: keyof T;
|
identifierColumnName: keyof T;
|
||||||
identifierValue: string | number;
|
identifierValue: string | number;
|
||||||
forceLocal?: boolean;
|
forceLocal?: boolean;
|
||||||
|
debug?: boolean;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* # Update DB Function
|
* # Update DB Function
|
||||||
@ -20,5 +21,5 @@ type Param<T extends {
|
|||||||
*/
|
*/
|
||||||
export default function updateDbEntry<T extends {
|
export default function updateDbEntry<T extends {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
} = any>({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, }: Param<T>): Promise<APIResponseObject<PostInsertReturn>>;
|
} = any>({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, }: Param<T>): Promise<APIResponseObject<PostInsertReturn>>;
|
||||||
export {};
|
export {};
|
||||||
|
@ -25,7 +25,7 @@ const purge_default_fields_1 = __importDefault(require("../../../utils/purge-def
|
|||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
function updateDbEntry(_a) {
|
function updateDbEntry(_a) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, }) {
|
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, }) {
|
||||||
var _b;
|
var _b;
|
||||||
/**
|
/**
|
||||||
* Check if data is valid
|
* Check if data is valid
|
||||||
@ -139,6 +139,7 @@ function updateDbEntry(_a) {
|
|||||||
sql: query,
|
sql: query,
|
||||||
params: updateValues,
|
params: updateValues,
|
||||||
},
|
},
|
||||||
|
debug: debug ? { data, newData } : undefined,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ const addDbEntry_1 = __importDefault(require("../../functions/backend/db/addDbEn
|
|||||||
const updateDbEntry_1 = __importDefault(require("../../functions/backend/db/updateDbEntry"));
|
const updateDbEntry_1 = __importDefault(require("../../functions/backend/db/updateDbEntry"));
|
||||||
function dsqlCrud(params) {
|
function dsqlCrud(params) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, } = params;
|
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, } = params;
|
||||||
const finalData = (sanitize ? sanitize({ data }) : data);
|
const finalData = (sanitize ? sanitize({ data }) : data);
|
||||||
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
||||||
const DB_CONN = global.DSQL_READ_ONLY_DB_CONN || global.DSQL_DB_CONN;
|
const DB_CONN = global.DSQL_READ_ONLY_DB_CONN || global.DSQL_DB_CONN;
|
||||||
@ -35,6 +35,7 @@ function dsqlCrud(params) {
|
|||||||
batchData: finalBatchData,
|
batchData: finalBatchData,
|
||||||
tableName: table,
|
tableName: table,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
|
debug,
|
||||||
});
|
});
|
||||||
return INSERT_RESULT;
|
return INSERT_RESULT;
|
||||||
case "update":
|
case "update":
|
||||||
@ -45,6 +46,7 @@ function dsqlCrud(params) {
|
|||||||
dbFullName,
|
dbFullName,
|
||||||
identifierColumnName: (targetField || "id"),
|
identifierColumnName: (targetField || "id"),
|
||||||
identifierValue: String(targetValue || targetId),
|
identifierValue: String(targetValue || targetId),
|
||||||
|
debug,
|
||||||
});
|
});
|
||||||
return UPDATE_RESULT;
|
return UPDATE_RESULT;
|
||||||
case "delete":
|
case "delete":
|
||||||
|
@ -14,10 +14,13 @@ function setupGlobalNetwork() {
|
|||||||
(0, child_process_1.execSync)(`docker network rm ${globalNetworkName}`, {});
|
(0, child_process_1.execSync)(`docker network rm ${globalNetworkName}`, {});
|
||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
let newNtwkCmd = `docker network create`;
|
try {
|
||||||
newNtwkCmd += ` --driver bridge`;
|
let newNtwkCmd = `docker network create`;
|
||||||
newNtwkCmd += ` --subnet ${globalIPPrefix}.0/24`;
|
newNtwkCmd += ` --driver bridge`;
|
||||||
newNtwkCmd += ` --gateway ${globalIPPrefix}.1`;
|
newNtwkCmd += ` --subnet ${globalIPPrefix}.0/24`;
|
||||||
newNtwkCmd += ` ${globalNetworkName}`;
|
newNtwkCmd += ` --gateway ${globalIPPrefix}.1`;
|
||||||
(0, child_process_1.execSync)(newNtwkCmd);
|
newNtwkCmd += ` ${globalNetworkName}`;
|
||||||
|
(0, child_process_1.execSync)(newNtwkCmd);
|
||||||
|
}
|
||||||
|
catch (error) { }
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ type Param<T extends { [k: string]: any } = any> = {
|
|||||||
identifierColumnName: keyof T;
|
identifierColumnName: keyof T;
|
||||||
identifierValue: string | number;
|
identifierValue: string | number;
|
||||||
forceLocal?: boolean;
|
forceLocal?: boolean;
|
||||||
|
debug?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,6 +43,7 @@ export default async function updateDbEntry<
|
|||||||
encryptionKey,
|
encryptionKey,
|
||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
forceLocal,
|
forceLocal,
|
||||||
|
debug,
|
||||||
}: Param<T>): Promise<APIResponseObject<PostInsertReturn>> {
|
}: Param<T>): Promise<APIResponseObject<PostInsertReturn>> {
|
||||||
/**
|
/**
|
||||||
* Check if data is valid
|
* Check if data is valid
|
||||||
@ -192,5 +194,6 @@ export default async function updateDbEntry<
|
|||||||
sql: query,
|
sql: query,
|
||||||
params: updateValues,
|
params: updateValues,
|
||||||
},
|
},
|
||||||
|
debug: debug ? { data, newData } : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import sqlDeleteGenerator from "../../functions/dsql/sql/sql-delete-generator";
|
import sqlDeleteGenerator from "../../functions/dsql/sql/sql-delete-generator";
|
||||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
|
||||||
import {
|
import {
|
||||||
APIResponseObject,
|
APIResponseObject,
|
||||||
DsqlCrudParam,
|
DsqlCrudParam,
|
||||||
DSQLErrorObject,
|
|
||||||
PostInsertReturn,
|
PostInsertReturn,
|
||||||
PostReturn,
|
|
||||||
} from "../../types";
|
} from "../../types";
|
||||||
import dsqlCrudGet from "./crud-get";
|
import dsqlCrudGet from "./crud-get";
|
||||||
import connDbHandler from "../db/conn-db-handler";
|
import connDbHandler from "../db/conn-db-handler";
|
||||||
@ -28,7 +25,9 @@ export default async function dsqlCrud<
|
|||||||
deleteData,
|
deleteData,
|
||||||
batchData,
|
batchData,
|
||||||
deleteKeyValues,
|
deleteKeyValues,
|
||||||
|
debug,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const finalData = (sanitize ? sanitize({ data }) : data) as T;
|
const finalData = (sanitize ? sanitize({ data }) : data) as T;
|
||||||
const finalBatchData = (
|
const finalBatchData = (
|
||||||
sanitize ? sanitize({ batchData }) : batchData
|
sanitize ? sanitize({ batchData }) : batchData
|
||||||
@ -49,6 +48,7 @@ export default async function dsqlCrud<
|
|||||||
batchData: finalBatchData,
|
batchData: finalBatchData,
|
||||||
tableName: table,
|
tableName: table,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
|
debug,
|
||||||
});
|
});
|
||||||
return INSERT_RESULT;
|
return INSERT_RESULT;
|
||||||
|
|
||||||
@ -61,6 +61,7 @@ export default async function dsqlCrud<
|
|||||||
dbFullName,
|
dbFullName,
|
||||||
identifierColumnName: (targetField || "id") as string,
|
identifierColumnName: (targetField || "id") as string,
|
||||||
identifierValue: String(targetValue || targetId),
|
identifierValue: String(targetValue || targetId),
|
||||||
|
debug,
|
||||||
});
|
});
|
||||||
|
|
||||||
return UPDATE_RESULT;
|
return UPDATE_RESULT;
|
||||||
|
@ -10,11 +10,13 @@ export default function setupGlobalNetwork() {
|
|||||||
execSync(`docker network rm ${globalNetworkName}`, {});
|
execSync(`docker network rm ${globalNetworkName}`, {});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
let newNtwkCmd = `docker network create`;
|
try {
|
||||||
newNtwkCmd += ` --driver bridge`;
|
let newNtwkCmd = `docker network create`;
|
||||||
newNtwkCmd += ` --subnet ${globalIPPrefix}.0/24`;
|
newNtwkCmd += ` --driver bridge`;
|
||||||
newNtwkCmd += ` --gateway ${globalIPPrefix}.1`;
|
newNtwkCmd += ` --subnet ${globalIPPrefix}.0/24`;
|
||||||
newNtwkCmd += ` ${globalNetworkName}`;
|
newNtwkCmd += ` --gateway ${globalIPPrefix}.1`;
|
||||||
|
newNtwkCmd += ` ${globalNetworkName}`;
|
||||||
|
|
||||||
execSync(newNtwkCmd);
|
execSync(newNtwkCmd);
|
||||||
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "4.8.5",
|
"version": "4.8.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