MongoDB Models
This page explains how to create your own MongoDB models for your AthenaBot plugin.
1. Setting up the MongoDB model file
Copy the model template.
const modelBuilder = require('../../../../main/core/database/modelBuilder.js');
module.exports = class testModel extends modelBuilder {
constructor() {
super('test', {
version: Number,
guildId: String,
id: String,
});
}
};Create a new model file inside your
/plugins/<plugin_name>/src/models/directory.The name of the file must follow the format
<model_name>.js.
Parameters
'test': A unique identifier for the model.'object': This follows the same model definition approach you may already know from Mongoose.
2. Importing models
Add the following snippet to your code to import any MongoDB model:
This returns a Mongoose model instance. With this instance, you can search, delete, insert, or modify datasets.
Last updated