TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Priyanshu471/ad-management/llms.txt
Use this file to discover all available pages before exploring further.
User model represents a registered account in the Ad Management System. Defined in models/user.ts, it uses a Mongoose schema to persist user credentials and role assignments to MongoDB. Every campaign belongs to a user, making this model the root of all ownership relationships in the platform.
Schema
models/user.ts
Fields
Auto-generated unique identifier assigned by MongoDB on document creation.
The user’s display name shown across the dashboard.
The user’s email address. Must be unique across all accounts and is used as the login identifier.
The user’s password. See the security warning below regarding the current storage implementation.
Determines which dashboard the user is directed to after login. The schema accepts any string — the conventional application values are
admin, advertiser, and creator.Timestamp automatically set by Mongoose when the document is first created.
Timestamp automatically updated by Mongoose whenever the document is modified.
Sample Document
Role Values
Therole field controls routing after a successful login. The schema stores any string — no enum validation is applied at the database layer. The conventional values used by the application are:
| Value | Dashboard |
|---|---|
admin | /admin |
advertiser | /advertiser |
creator | /creator |
Model Registration Pattern
The model is exported using the guard pattern:"Cannot overwrite model once compiled" error in Next.js hot-reload environments. During development, Next.js re-executes module code on every hot reload. Without this guard, each reload would attempt to recompile the User model against a connection that already has it registered. The models.User check short-circuits that path and returns the already-compiled model instead.