-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.ts
More file actions
35 lines (29 loc) · 649 Bytes
/
Copy pathuser.ts
File metadata and controls
35 lines (29 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Collection, createFireclass } from "@dharayush7/fireclass-js";
import {
IsEmail,
IsInt,
IsOptional,
IsString,
Length,
Min,
} from "class-validator";
import { getDb } from "../firebase.js";
// Bind Fireclass to this app's Firestore once; reuse BaseModel everywhere.
const { BaseModel } = createFireclass(getDb());
@Collection("users")
export class User extends BaseModel<User> {
@IsString()
@Length(2, 50)
name!: string;
@IsEmail()
email!: string;
@IsInt()
@Min(0)
age!: number;
@IsOptional()
createdAt?: Date;
constructor(data?: Partial<User>) {
super(data);
Object.assign(this, data);
}
}