8d0cbad8b6
Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
20 lines
552 B
TypeScript
20 lines
552 B
TypeScript
import { getAllRegisteredDbClients } from '@/modules/multiregion/utils/dbSelector'
|
|
|
|
export type CommonDbArgs = {
|
|
regionKey?: string
|
|
}
|
|
|
|
export const getTargettedDbClients = async (params: { regionKey?: string }) => {
|
|
const { regionKey } = params
|
|
const dbs = (await getAllRegisteredDbClients()).filter((db) => {
|
|
if (!regionKey) return true
|
|
if (regionKey === 'main') return db.isMain
|
|
if (regionKey.includes(',')) {
|
|
return regionKey.split(',').includes(db.regionKey)
|
|
}
|
|
return db.regionKey === regionKey
|
|
})
|
|
|
|
return dbs
|
|
}
|