UNPKG

@clickup/pg-microsharding

Version:
19 lines 930 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.discoverShards = discoverShards; const flatten_1 = __importDefault(require("lodash/flatten")); const listActiveSchemas_1 = require("./listActiveSchemas"); const names_1 = require("./names"); const promiseAllMap_1 = require("./promiseAllMap"); /** * Loads the list of all active schemas from the given DSNs. */ async function discoverShards({ dsns, }) { return (0, flatten_1.default)(await (0, promiseAllMap_1.promiseAllMap)(dsns, async (dsn) => (await (0, listActiveSchemas_1.listActiveSchemas)({ dsn })) .filter((schema) => (0, names_1.shardNo)(schema) !== null) .map((schema) => ({ dsn, shard: (0, names_1.shardNo)(schema), schema })))); } //# sourceMappingURL=discoverShards.js.map