简体   繁体   中英

Are Entities between two sub-apps in NestJs sharable?

I am very new to NestJS and I am trying to create a project with multiple subapps. The query that I have is, if one entity is present in one sub-app, can we use that same entity in another sub-app of the same project?

This is my project strucutre:

  • apps
  • subApp1
  • entities - entityone.ts
  • controller, modules and services
  • subApp2
  • entities - entityTWo.ts
  • controller, modules and services

I want to use the entity one in subApp2 service. Is it possible? If so, how we can acheive this? Is there any better way to approach this situation where I need to use Entity of one sub app into another.

I tried exporting the Entity from one sub-app and import the Module in another sub app. But I am getting this error:

Nest cannot export a provider/module that is not a part of the currently processed module (StoreModule). Please verify whether the exported Store is available in this particular context.

I am not sure, if it was the correct way for this situation, but this solution came into my mind and i tried it.

you don't need to specify entities for every module .

keep them all together apart, so you can use them wherever you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM