ig-costing / lib /mongodb.ts
imkrish's picture
deploy 09214549
020ed68 verified
Raw History Blame Contribute Delete
547 Bytes
import { Db } from 'mongodb'
import { shards } from './mongoPool'
/**
* Single-shard accessor for the costing group, kept so routes that haven't been
* taught to fan out keep working unchanged.
*
* Safe while costing fits on one cluster - at ~0.3MB/day that is roughly 4.6
* years on a 512MB M0. Routes still using this will silently read only shard 0
* once costing spills, so they need converting to fanout() before that happens.
*/
export async function getDb(): Promise<Db> {
const [first] = await shards('costing')
return first
}