AdminService
Source: AdminService.js:16
Service for managing admin entities and their operations. Handles CRUD operations and admin-specific logic.
Constructor
new AdminService(): AdminServiceInstance Methods
findOrCreate(
username: string,
password: string,
): Promise.<Array.<(Admin|boolean)>>
async
AdminService.js:23Find or create an Admin by username. If not found, creates a new Admin with the given password.
Parameters
username(string) — The admin's username.password(string) — The admin's password.
Returns
Promise.<Array.<(Admin|boolean)>>— The found or newly created Admin instance and a boolean indicating if it was created.
findByUsername(
username: string,
options: Object,
): Promise.<(Admin|null)>
Find an Admin by username.
Parameters
username(string) — The admin's username.options(Object) — Options object.options.scope(string, optional, default: "\"defaultScope\"") — Sequelize scope to use.
Returns
Promise.<(Admin|null)>— The found Admin or null if not found.
findById(id: UUID): Promise.<(Admin|null)>
Find an Admin by its ID.
Parameters
id(UUID) — The admin's UUID.
Returns
Promise.<(Admin|null)>— The found Admin or null if not found.
getCount(): Promise.<number>
Get the total number of Admins in the database.
Returns
Promise.<number>— The count of Admins.
getAll(): Promise.<Array.<Admin>>
Get all Admins in the database.
Returns
Promise.<Array.<Admin>>— Array of all Admins.
getTrend(): Promise.<number>
Get the trend of Admins (new minus deleted) in the last 30 days.
Returns
Promise.<number>— The net number of Admins added in the last 30 days.
update(id: UUID, data: Object): Promise.<Admin>
Update an Admin by ID.
Parameters
id(UUID) — The admin's UUID.data(Object) — The update data.
Returns
Promise.<Admin>— The updated Admin instance.
Throws
Error— If no Admin with the given ID is found.
remove(id: UUID): Promise.<void>
Delete an Admin by ID.
Parameters
id(UUID) — The admin's UUID.
Returns
Promise.<void>— Resolves if deletion is successful.
Throws
Error— If no Admin with the given ID is found.