Skip to main content

⚙️ Database Configurations

Ensure that you add the database configurations in the src/config/database.ts file.

src/config/database.ts
import { env } from "@mongez/dotenv";
import { DatabaseConfigurations } from "@warlock.js/cascade";

const databaseConfigurations: DatabaseConfigurations = {
host: env("DB_HOST", "localhost"),
port: env("DB_PORT", 27017),
username: env("DB_USERNAME"),
password: env("DB_PASSWORD"),
database: env("DB_NAME"),
dbAuth: env("DB_AUTH"),
url: env("DB_URL"),
model: {
autoIncrementBy: 1,
initialId: 1,
},
};

export default databaseConfigurations;

🔍 Configuration Guide

  • host: Specifies the database server's host address. Defaults to localhost if not provided.
  • port: Defines the port on which the database server is running. Defaults to 27017 for MongoDB.
  • username: The username used for authenticating with the database.
  • password: The password associated with the database username.
  • database: The name of the database to connect to.
  • dbAuth: The authentication database, used for user authentication.
  • url: A complete connection URL. If provided, it overrides other configurations.
  • model.autoIncrementBy: Sets the increment step for auto-increment fields.
  • model.initialId: Defines the starting value for auto-increment fields.

If the url is provided, other configurations will be ignored; otherwise, the URL will be generated from the other configurations.

For more detailed information about database configurations, please refer to Cascade Configurations.