removido registros undefined
This commit is contained in:
parent
4860b2c036
commit
ceab73c21c
4 changed files with 29 additions and 4 deletions
|
|
@ -30,7 +30,9 @@ export const enviar_registros = ({ conta, produto, emDesenvolvimento }) => ({ re
|
||||||
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${PREFIXO}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`);
|
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${PREFIXO}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`);
|
||||||
const tamanhoBlocos = 1000;
|
const tamanhoBlocos = 1000;
|
||||||
while (registros.length > 0) {
|
while (registros.length > 0) {
|
||||||
const bloco = registros.splice(0, tamanhoBlocos);
|
const bloco = registros
|
||||||
|
.splice(0, tamanhoBlocos)
|
||||||
|
.map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v])));
|
||||||
const resp = yield node_fetch(url.toString(), {
|
const resp = yield node_fetch(url.toString(), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ tabela, registros: bloco }),
|
body: JSON.stringify({ tabela, registros: bloco }),
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var __read = (this && this.__read) || function (o, n) {
|
||||||
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||||
|
if (!m) return o;
|
||||||
|
var i = m.call(o), r, ar = [], e;
|
||||||
|
try {
|
||||||
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||||
|
}
|
||||||
|
catch (error) { e = { error: error }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||||
|
}
|
||||||
|
finally { if (e) throw e.error; }
|
||||||
|
}
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
|
|
@ -73,7 +89,14 @@ var enviar_registros = function (_a) {
|
||||||
_b.label = 1;
|
_b.label = 1;
|
||||||
case 1:
|
case 1:
|
||||||
if (!(registros.length > 0)) return [3 /*break*/, 3];
|
if (!(registros.length > 0)) return [3 /*break*/, 3];
|
||||||
bloco = registros.splice(0, tamanhoBlocos);
|
bloco = registros
|
||||||
|
.splice(0, tamanhoBlocos)
|
||||||
|
.map(function (r) {
|
||||||
|
return Object.fromEntries(Object.entries(r).map(function (_a) {
|
||||||
|
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
||||||
|
return [k, v === undefined ? null : v];
|
||||||
|
}));
|
||||||
|
});
|
||||||
return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), {
|
return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ tabela: tabela, registros: bloco }),
|
body: JSON.stringify({ tabela: tabela, registros: bloco }),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-drives",
|
"name": "p-drives",
|
||||||
"version": "0.84.0",
|
"version": "0.86.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import node_fetch from "cross-fetch"
|
import node_fetch from "cross-fetch"
|
||||||
import type { tipoResposta } from "p-respostas"
|
import type { tipoResposta } from "p-respostas"
|
||||||
import { respostaComuns } from "p-respostas"
|
import { respostaComuns } from "p-respostas"
|
||||||
import { map, z } from "zod"
|
import { z } from "zod"
|
||||||
import {
|
import {
|
||||||
PREFIXO,
|
PREFIXO,
|
||||||
baseUrlPilao,
|
baseUrlPilao,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue