Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 1x | import mongoose, { Schema } from 'mongoose';
import { IUser , UserData} from 'types/user_types';
const userSchema: Schema = new Schema({
username: { type: String, required: true },
email: { type: String, required: true },
password: { type: String, required: true }, // Store hashed passwords
}, { timestamps: true });
userSchema.set('toJSON', {
transform: (doc, ret): UserData => {
return {
id: ret._id,
username: ret.username,
email: ret.email,
createdAt: ret.createdAt,
updatedAt: ret.updatedAt
};
}
});
export const UserModel = mongoose.model<IUser>('User', userSchema); |