MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / createHashPartitions

Function createHashPartitions

packages/sql/src/schema/partitioning.ts:318–335  ·  view source on GitHub ↗
(
  tableName: string,
  tableSchema: string | undefined,
  partitions: number | readonly string[],
)

Source from the content-addressed store, hash-verified

316const createPartitionBound = (value: string): string => normalizePartitionBound(value);
317
318const createHashPartitions = (
319 tableName: string,
320 tableSchema: string | undefined,
321 partitions: number | readonly string[],
322): TablePartition[] => {
323 const count = typeof partitions === 'number' ? partitions : partitions.length;
324
325 return Array.from({ length: count }, (_, remainder) => {
326 const bound = normalizePartitionBound(`with (modulus ${count}, remainder ${remainder})`);
327
328 if (typeof partitions === 'number') {
329 return { name: `${tableName}_${remainder}`, schema: tableSchema, bound };
330 }
331
332 const { name, schema } = splitPartitionName(partitions[remainder]);
333 return { name, schema: schema ?? tableSchema, bound };
334 });
335};
336
337const createExplicitPartitions = (
338 tableName: string,

Callers 1

getTablePartitioningFunction · 0.85

Calls 3

normalizePartitionBoundFunction · 0.85
splitPartitionNameFunction · 0.85
fromMethod · 0.65

Tested by

no test coverage detected