- Add event persistence: confirmed events are now saved to MongoDB - Refactor Mongoose models to use virtuals for id field with IdVirtual interface - Update repositories to use toJSON() with consistent type casting - Add more test responses for chat (doctor, birthday, gym, etc.) - Show event description in ProposedEventCard - Change mongo-express port to 8083 - Update CLAUDE.md with Mongoose model pattern documentation
22 lines
863 B
TypeScript
22 lines
863 B
TypeScript
import { User } from '@caldav/shared';
|
|
import { UserRepository, CreateUserData } from '../../services/interfaces';
|
|
import { UserModel } from './models';
|
|
|
|
export class MongoUserRepository implements UserRepository {
|
|
async findById(id: string): Promise<User | null> {
|
|
throw new Error('Not implemented');
|
|
}
|
|
|
|
async findByEmail(email: string): Promise<User | null> {
|
|
const user = await UserModel.findOne({ email: email.toLowerCase() });
|
|
// NOTE: Casting required because Mongoose's toJSON() type doesn't reflect our virtual 'id' field
|
|
return (user?.toJSON() as unknown as User) ?? null;
|
|
}
|
|
|
|
async create(data: CreateUserData): Promise<User> {
|
|
const user = await UserModel.create(data);
|
|
// NOTE: Casting required because Mongoose's toJSON() type doesn't reflect our virtual 'id' field
|
|
return user.toJSON() as unknown as User;
|
|
}
|
|
}
|