refactor(data-schemas): update model and method creation for improved modularity

- Refactored model creation functions to enhance clarity and consistency across the data-schemas.
- Introduced createModels and createMethods functions to streamline the instantiation of Mongoose models and methods.
- Updated test-role.js to utilize the new createModels and createMethods for better organization.
This commit is contained in:
Danny Avila 2025-05-30 12:20:01 -04:00
parent 728d19e361
commit 76e070048c
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
15 changed files with 107 additions and 117 deletions

View file

@ -6,7 +6,7 @@ import { createRoleMethods, type RoleMethods } from './role';
/**
* Creates all database methods for all collections
*/
export function createAllMethods(mongoose: typeof import('mongoose')) {
export function createMethods(mongoose: typeof import('mongoose')) {
return {
...createUserMethods(mongoose),
...createSessionMethods(mongoose),
@ -16,9 +16,3 @@ export function createAllMethods(mongoose: typeof import('mongoose')) {
}
export type AllMethods = UserMethods & SessionMethods & TokenMethods & RoleMethods;
// Also export individual factory functions for granular usage if needed
export { createUserMethods, type UserMethods } from './user';
export { createSessionMethods, type SessionMethods } from './session';
export { createTokenMethods, type TokenMethods } from './token';
export { createRoleMethods, type RoleMethods } from './role';