@ultipa-graph/ultipa-node-sdk
Version:
NodeJS SDK for ultipa-server 4.0
49 lines • 1.86 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.printEdge = exports.getEdgesPrintInfo = void 0;
const chalk_1 = __importDefault(require("chalk"));
const types_1 = require("../types");
const alias_1 = require("./alias");
function getEdgesPrintInfo(edges, option) {
let schemaMap = {};
let rows = [];
edges === null || edges === void 0 ? void 0 : edges.forEach((n, i) => {
let schema = n === null || n === void 0 ? void 0 : n.schema;
if (!n) {
schema = "printers_null_edges";
}
if (!schemaMap[schema]) {
schemaMap[schema] = [];
}
let row = !n ? {
null_index: i
} : Object.assign({ "@schema": schema, _uuid: n.uuid, _from: n.from, _to: n.to, _from_uuid: n.from_uuid, _to_uuid: n.to_uuid }, n.values);
if (option === null || option === void 0 ? void 0 : option.onlyRows) {
rows.push(row);
}
else {
schemaMap[schema].push(row);
}
});
if (option === null || option === void 0 ? void 0 : option.onlyRows) {
return rows;
}
return schemaMap;
}
exports.getEdgesPrintInfo = getEdgesPrintInfo;
function printEdge(dataItem) {
if ((dataItem === null || dataItem === void 0 ? void 0 : dataItem.type) == types_1.ULTIPA.ResultType.RESULT_TYPE_EDGE) {
let edges = dataItem.asEdges();
(0, alias_1.printAlias)(dataItem);
let schemaMap = getEdgesPrintInfo(edges);
for (const schema in schemaMap) {
console.log(chalk_1.default.blue(` @${schema}`));
console.table(schemaMap[schema]);
}
}
}
exports.printEdge = printEdge;
//# sourceMappingURL=edge.js.map