Skip to content

Commit

Permalink
[#7] refactor: move model instantiation to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
glemenneo committed Sep 18, 2024
1 parent f568045 commit bebf79e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 2 additions & 4 deletions backend/user-service/src/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Schema, model } from 'mongoose'
import { Schema } from 'mongoose'
import { IUser } from '../types/IUser'
import { Proficiency } from '../types/Proficiency'
import { Role } from '../types/Role'

const UserSchema = new Schema<IUser>({
export default new Schema<IUser>({
username: {
type: String,
required: true,
Expand Down Expand Up @@ -43,5 +43,3 @@ const UserSchema = new Schema<IUser>({
default: null,
},
})

export default model<IUser>('User', UserSchema)
5 changes: 4 additions & 1 deletion backend/user-service/src/models/user.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Model, model } from 'mongoose'
import { CreateUserDto } from '../types/CreateUserDto'
import { IUser } from '../types/IUser'
import { UserDto } from '../types/UserDto'
import userModel from './user.model'
import userSchema from './user.model'

const userModel: Model<IUser> = model('User', userSchema)

export async function findAllUsers(): Promise<IUser[]> {
return userModel.find()
Expand Down

0 comments on commit bebf79e

Please sign in to comment.