Mongoose
@adminjs/mongoose
Last updated
@adminjs/mongoose
Last updated
This guide will assume you have set up Mongoose using it's or .
There are small differences in how you connect Mongoose to Nest.js vs other plugins, so the guide will be split into two sections accordingly.
Example model:
The configuration for non-Nest.js plugins is basically the same for each one of them:
You must connect to Mongo before creating AdminJS
instance
You must import AdminJSMongoose
adapter and register it
You must import the entities you want to use and pass them to AdminJS resources
options
Your app.module.ts
should have imports
option which contains:
MongooseModule.forRoot('<mongo db url>')
to set up Mongoose
AdminModule.createAdminAsync({ ... }
In your app.module.ts
add these imports at the top of the file:
Following this, register AdminJSMongoose
adapter somewhere after your imports:
This will allow you to pass Mongoose models for AdminJS to load. If we use the Category
entity that we used as en example earlier, you should import it into app.module.ts
and pass it into resources
in your adminJsOptions
:
Make sure you have followed the tutorial for the framework you are using in the section.
Make sure you have set up your app.module.ts
according to and you have followed as well.