I try to use await in class constructor but failed, here are my trys:
export class TheHistory {
constructor(private readonly db: EntityManager){
//try1: too many levels !!! try use await
mydb.insert(god).then(() => {
mydb.insert(human).then(() => {
mydb.insert(city).then(() => {
//.....
})
})
})
//try2: ERROR -- 'await'expressions are only allowed within async functions and at the top levels of modules
await mydb.insert(god)
await mydb.insert(human)
await mydb.insert(city)
}
}