TypeORM
@adminjs/typeorm
Last updated
// ... other imports
import * as AdminJSTypeorm from '@adminjs/typeorm'
import dataSource from './path/to/your/datasource.js'
import { Organization } from './organization.entity.js'
AdminJS.registerAdapter({
Resource: AdminJSTypeorm.Resource,
Database: AdminJSTypeorm.Database,
})
// ... other code
const start = async () => {
// Make sure you initialize the data source before you create your AdminJS instance
await dataSource.initialize()
const adminOptions = {
// We pass Organization to `resources`
resources: [Organization],
}
// Please note that some plugins don't need you to create AdminJS instance manually,
// instead you would just pass `adminOptions` into the plugin directly,
// an example would be "@adminjs/hapi"
const admin = new AdminJS(adminOptions)
// ... other code
}
start()import * as AdminJSTypeorm from '@adminjs/typeorm'
import AdminJS from 'adminjs'AdminJS.registerAdapter({
Resource: AdminJSTypeorm.Resource,
Database: AdminJSTypeorm.Database,
})// ... other imports
import { Organization } from './organization.entity.js'
// ... other code
AdminModule.createAdminAsync({
useFactory: () => ({
adminJsOptions: {
rootPath: '/admin',
resources: [Organization],
},
}),
}),
// ... other code