postgresql, typeorm
how can we check whether a table already exists in a database before starting database operations on that table?
currently my code is like this, i check whether an item is present in database. But the problem with this approach is that, if its a fresh deployment, and if the tables are not present, then an exception is thrown.
const found = await this.userRepository.findOne(undefined); //<<< throws exception if tables not already created
if (found === undefined) {
const item: Items = this.userRepository.create({....});
}
so how can we add a check for a table's existance first, before doing database operations on it?