Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to seed data with monorepo workspace in nestjs #236

Open
Sotatek-PhuongNguyen4 opened this issue Nov 18, 2022 · 4 comments
Open

How to seed data with monorepo workspace in nestjs #236

Sotatek-PhuongNguyen4 opened this issue Nov 18, 2022 · 4 comments

Comments

@Sotatek-PhuongNguyen4
Copy link

Sotatek-PhuongNguyen4 commented Nov 18, 2022

I use monorepo to build the applications. I've some apps and libs

My code folder is below. How to write typeorm config file in my case for seeding data.

image

ormconfig.ts
image

package json seeding script

image

Error
image

The codebuild only has the main.js file. It doesn't have some file like .entity.js. So I think my ormconfig.ts file is wrong. Please help. Thanks you guys a lot.

@weilinzung
Copy link

@Sotatek-PhuongNguyen4 we are having the same issue that the lib import doesn't resolve right. Have you figured it out yet?

@Sotatek-PhuongNguyen4
Copy link
Author

@weilinzung I resolved this problem by creating SeederModule and run it as application context to initialize database. In each module, I run service to insert data directly to database. I hop It's helpful for you.
image
image
image

@dlhck
Copy link

dlhck commented Mar 15, 2024

@Sotatek-PhuongNguyen4 any update on this one? Have you found a solution that works together with Nest.js? Thank you!

@Sotatek-PhuongNguyen4
Copy link
Author

@Sotatek-PhuongNguyen4 any update on this one? Have you found a solution that works together with Nest.js? Thank you!

@davidhoeck As I commented above, I seeded data manually by using standalone application feature. Read more:
https://docs.nestjs.com/faq/serverless#using-standalone-application-feature
The main idea here is call directly to database to insert datas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants