You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
539 B
26 lines
539 B
import { BaseDatabase } from 'adminjs'
|
|
import type { Connection } from 'mongoose'
|
|
|
|
import Resource from './resource'
|
|
|
|
class Database extends BaseDatabase {
|
|
private readonly connection: Connection;
|
|
|
|
constructor(connection) {
|
|
super(connection)
|
|
this.connection = connection
|
|
}
|
|
|
|
static isAdapterFor(connection) {
|
|
return connection.constructor.name === 'Mongoose'
|
|
}
|
|
|
|
resources() {
|
|
return this.connection.modelNames().map(name => (
|
|
new Resource(this.connection.model(name))
|
|
))
|
|
}
|
|
}
|
|
|
|
export default Database
|