当我尝试在 Nest.js/typeorm 和 postgres 中设置 AdminBro 时,出现此错误: UnhandledPromiseRejectionWarning: NoResourceAdapterError: 没有适配器支持您提供的资源之一。
你能帮我找到解决这个问题的方法吗?这是我设置的adminBro:
export async function setupAdminPanel(app: INestApplication): Promise<void> {
AdminBro.registerAdapter({ Database, Resource });
const adminBro = new AdminBro({
resources: [{resource: User}],
rootPath: '/admin'
});
const router = AdminBroExpress.buildRouter(adminBro);
app.use(adminBro.options.rootPath, router);
}
这是我的用户实体文件:
@Entity()
export class User extends BaseEntity {
@Column()
firstName: string;
@Column()
lastName: string;
}
我以这种方式定义我的 baseEntity :
import { CreateDateColumn, PrimaryGeneratedColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm';
export class BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@CreateDateColumn()
createdDate: Date;
@UpdateDateColumn()
updatedDate: Date;
@DeleteDateColumn()
deletedDate: Date;
}
这是 main.js 文件:
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await setupAdminPanel(app);
await app.listen(3000);
}
bootstrap();