Theodo-UK / nestjs-admin

A generic administration interface for TypeORM entities
https://nestjs-admin.com
MIT License
536 stars 60 forks source link

Support for TypeOrmModule.forRootAsync #115

Open Samox opened 5 years ago

Samox commented 5 years ago

Hello, I'm facing the following issue. Is TypeOrmModule.forRootAsync supported ?

image

williamdclt commented 5 years ago

It should, I don't think the lib is dependent on whether you use forRoot or forRootAsync.

It looks like the AdminEntity isn't discovered by TypeORM, could you paste your orm config here? In particular, did you do this:

// If you use an ormconfig.js
const AdminUser = require('nestjs-admin').AdminUserEntity
module.exports = {
  /* ... */,
  entities: [/* ... */, AdminUser],
  // Alternatively:
  // entities: [/* ... */, 'node_modules/nestjs-admin/**/*.entity.js'],
}
# If you use environment variables
TYPEORM_ENTITIES=your_existing_paths,node_modules/nestjs-admin/**/*.entity.js
almarto commented 5 years ago

I've followed the docs, I have an ormconfig.json file so I added to the entities 'node_modules/nestjs-admin/**/*.entity.js' but then my DataBase is corrupted with the nestjs admin example and test entities.

I've tried to scope better the entities which the typeorm have to had into account using this configuration 'node_modules/nestjs-admin/dist/src/adminUser.entity.js' and it has worked well.

I hope this helps you @Samox.

@williamdclt shall I create a PR with the docs updated?

williamdclt commented 5 years ago

@almarto Thanks for reporting! It shouldn't happen, the AdminUser should be the only entity in there. I'll fix it ASAP!