converter objeto para postgres
This commit is contained in:
parent
f6dcff3693
commit
11b24c3b98
7 changed files with 106 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ __reExport(index_exports, require("./dayjs"), module.exports);
|
|||
__reExport(index_exports, require("./ecosistema"), module.exports);
|
||||
__reExport(index_exports, require("./extensoes"), module.exports);
|
||||
__reExport(index_exports, require("./logger"), module.exports);
|
||||
__reExport(index_exports, require("./postgres"), module.exports);
|
||||
__reExport(index_exports, require("./testes-de-variaveis"), module.exports);
|
||||
__reExport(index_exports, require("./texto_busca"), module.exports);
|
||||
__reExport(index_exports, require("./tipagemRotas"), module.exports);
|
||||
|
|
@ -39,6 +40,7 @@ __reExport(index_exports, require("./variaveisComuns"), module.exports);
|
|||
...require("./ecosistema"),
|
||||
...require("./extensoes"),
|
||||
...require("./logger"),
|
||||
...require("./postgres"),
|
||||
...require("./testes-de-variaveis"),
|
||||
...require("./texto_busca"),
|
||||
...require("./tipagemRotas"),
|
||||
|
|
|
|||
47
dist-back/postgres.js
Normal file
47
dist-back/postgres.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var postgres_exports = {};
|
||||
__export(postgres_exports, {
|
||||
objetoPg: () => objetoPg,
|
||||
paraObjetoRegistroPg: () => paraObjetoRegistroPg,
|
||||
pgObjeto: () => pgObjeto
|
||||
});
|
||||
module.exports = __toCommonJS(postgres_exports);
|
||||
const paraObjetoRegistroPg = (entrada) => {
|
||||
try {
|
||||
return Object.fromEntries(
|
||||
Object.entries(entrada).map(([k, v]) => [
|
||||
k,
|
||||
v === void 0 || v == null ? v : typeof v == "string" || typeof v == "number" || typeof v == "boolean" ? v : JSON.stringify(v, null, 2)
|
||||
])
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${error.message} ${error.stack}`
|
||||
);
|
||||
}
|
||||
};
|
||||
const pgObjeto = paraObjetoRegistroPg;
|
||||
const objetoPg = paraObjetoRegistroPg;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
objetoPg,
|
||||
paraObjetoRegistroPg,
|
||||
pgObjeto
|
||||
});
|
||||
|
|
@ -118,6 +118,27 @@ type tipoLogger = (amb: {
|
|||
}) => TipoLoggerSessao;
|
||||
declare const logger: tipoLogger;
|
||||
|
||||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
* @returns
|
||||
*/
|
||||
declare const paraObjetoRegistroPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const pgObjeto: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const objetoPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
|
||||
declare const umaFuncao: () => string;
|
||||
|
||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
||||
|
|
@ -243,4 +264,4 @@ declare const nomeVariavel: (v: {
|
|||
[key: string]: any;
|
||||
}) => string;
|
||||
|
||||
export { TipagemRotas, type TipoLoggerSessao, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, defineCwd, erUuid, esperar, extensoes, type interfaceConsulta, logger, nomeVariavel, operadores, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoLogger, type tipoLoggerLog, type tipoLokiObjeto, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM };
|
||||
export { TipagemRotas, type TipoLoggerSessao, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, defineCwd, erUuid, esperar, extensoes, type interfaceConsulta, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoLogger, type tipoLoggerLog, type tipoLokiObjeto, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM };
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "p-comuns",
|
||||
"version": "0.217.0",
|
||||
"version": "0.218.0",
|
||||
"description": "",
|
||||
"main": "./dist-back/index.js",
|
||||
"module": "./dist-front/index.mjs",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export * from "./dayjs"
|
|||
export * from "./ecosistema"
|
||||
export * from "./extensoes"
|
||||
export * from "./logger"
|
||||
export * from "./postgres"
|
||||
export * from "./testes-de-variaveis"
|
||||
export * from "./texto_busca"
|
||||
export * from "./tipagemRotas"
|
||||
|
|
|
|||
32
src/postgres.ts
Normal file
32
src/postgres.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
* @returns
|
||||
*/
|
||||
export const paraObjetoRegistroPg = (entrada: {
|
||||
[k: string]: any
|
||||
}): {
|
||||
[k: string]: string | boolean | null | undefined | number
|
||||
} => {
|
||||
try {
|
||||
return Object.fromEntries(
|
||||
Object.entries(entrada).map(([k, v]) => [
|
||||
k,
|
||||
v === undefined || v == null
|
||||
? v
|
||||
: typeof v == "string" ||
|
||||
typeof v == "number" ||
|
||||
typeof v == "boolean"
|
||||
? v
|
||||
: JSON.stringify(v, null, 2),
|
||||
]),
|
||||
)
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Erro na função paraObjetoRegistroPg: ${(error as Error).message} ${(error as Error).stack}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const pgObjeto = paraObjetoRegistroPg
|
||||
export const objetoPg = paraObjetoRegistroPg
|
||||
Loading…
Add table
Add a link
Reference in a new issue