Skip to content

basalt / prisma/src / ShardHash

Type Alias: ShardHash ​

> ShardHash = (key, shardCount) => number

Defined in: prisma/src/sharding.ts:11

Horizontal sharding: route a key (typically a tenant id) to one of a fixed set of database clients. The mapping is deterministic — the same key always lands on the same shard across processes and restarts — so a tenant's data always lives on the same database.

Unlike the per-tenant pool, shard clients are long-lived and shared by many tenants; nothing is evicted. Wire it with prismaPlugin({ shards }).

Parameters ​

key ​

string

shardCount ​

number

Returns ​

number

Released under the MIT License.