Creates a new SequelizeAdapter instance.
The adapter will automatically initialize the GiveawayModel using the provided
Sequelize instance. Make sure to call sequelize.sync()
to create the database
tables before using the adapter.
A configured Sequelize instance connected to your database
import { Sequelize } from 'sequelize';
const sequelize = new Sequelize({
dialect: 'postgres',
host: 'localhost',
database: 'giveaways',
username: 'user',
password: 'password',
logging: false // Set to console.log to see SQL queries
});
const adapter = new SequelizeAdapter(sequelize);
// Create tables if they don't exist
await sequelize.sync();
Saves or updates giveaway data in the database.
Uses Sequelize's upsert operation which will insert a new record if the giveaway doesn't exist, or update the existing record if it does.
The giveaway data to save
Retrieves a specific giveaway by its primary key (giveawayId).
The unique giveaway ID to retrieve
The giveaway data or null if not found
Retrieves all giveaways from the database.
An array of all giveaway data
Updates an existing giveaway with new data.
The giveaway ID to update
The new giveaway data
Database storage adapter using Sequelize ORM.
This adapter provides persistent storage for giveaway data using any SQL database supported by Sequelize (PostgreSQL, MySQL, MariaDB, SQLite, Microsoft SQL Server). It's ideal for production environments, larger bots, or when you need advanced database features like transactions, relationships, and complex queries.
Features:
Example