import { Collection } from './db' ; export class Validation { static async existsOrFail < T > ( collection , id , type ) { const doc = await collection . findOne ( { id : id } ) ; if ( ! doc ) { throw new Error ( `${ type } ${ id } not found` ) ; } return doc ; } }