add project creation and listing

This commit is contained in:
João Geonizeli
2022-07-09 10:05:01 -03:00
parent c3fe6e6f1c
commit e0dd6c2307
27 changed files with 256 additions and 26 deletions

View File

@@ -0,0 +1,18 @@
import { DataSource } from "typeorm";
export const cleanDataSource = async (
dataSource: DataSource,
entityNames: string[]
) => {
if (process.env.NODE_ENV !== "test") {
throw new Error(
`You tried to run a cleanDataSource into ${process.env.NODE_ENV} enviroment`
);
}
await Promise.all(
entityNames.map((tableName) => {
return dataSource.query(`DELETE FROM "${tableName}";`);
})
);
};