从1个具有不同名称的API查询多个表,但在Nestjs typeorm中相同的结构
我有一个有关Typeorm查询的问题。我正在设计一个应用程序,并且数据库已经存在。它写得很差,而且规模不错,客户不希望它更改。问题是,每个对象(我们称其为超市)在数据库中都有其自己的表。 例如: 超市纽约==> Supermart_ny_1 超市巴黎==> Supermart_par_1
表具有完全相同的数据类型,具有完全相同的名称,但表的名称不同。目前,由于我是Nest初学者,我创建了一个名为Supermart_ny_1的实体,现在当我为其编写API时,很明显,在服务中进行查询并注入存储库时,它需要为所有超市工作。我以为我可以为我的实体组成一个父班,其中包含所有必要列,但是当进行查询时,我仍然需要数据库的确切名称
I have a question regarding TypeORM queries. I am designing an app and the database was already existing. It is written poorly and is decent size and the customer doesn't want it changed. The problem is, each object (let's call it a supermarket) has it's own table in the database.
For example:
Supermarket New York ==> supermarket_ny_1
Supermarket Paris ==> supermarket_par_1
Tables have the exact same data types with exact same names, but the name of table is different. Currently, as i'm a nest beginner, i created an entity called supermarket_ny_1 and now when i'm writing the API for it, it's apparent that when making queries in a service and injecting repositories, it needs to work for all the supermarkets. I thought i could make a parent class for my entity that would contain all the neccessary columns, but when making a query i still need the exact name for the database
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论