* upgrade typeorm to 3.0 * use new datasource object in typeorm 3 * fix tests * fix tests * migrate before creating connection * fail the test if migration failed
17 lines
453 B
TypeScript
17 lines
453 B
TypeScript
import { EntityManager, EntityTarget, Repository } from 'typeorm'
|
|
import { AppDataSource } from '../server'
|
|
|
|
export const setClaims = async (
|
|
t: EntityManager,
|
|
uid: string
|
|
): Promise<void> => {
|
|
const dbRole = 'omnivore_user'
|
|
return t
|
|
.query('SELECT * from omnivore.set_claims($1, $2)', [uid, dbRole])
|
|
.then()
|
|
}
|
|
|
|
export const getRepository = <T>(entity: EntityTarget<T>): Repository<T> => {
|
|
return AppDataSource.getRepository(entity)
|
|
}
|