add types to models

This commit is contained in:
wancat committed 2024-02-19 18:05:01 +08:00
1 parent 5489de2432
commit 9dc0b43737
16 files changed
+179 -73

No files matched your search

+18 -5
View File
@@ -1,6 +1,12 @@
import { model, Schema } from 'mongoose'
const socialLoginSchema = new Schema({
export interface ISocialLogin {
provider: string
id: string
displayName?: string
}
const socialLoginSchema = new Schema<ISocialLogin>({
provider: {
type: String,
required: true,
@@ -15,9 +21,18 @@ const socialLoginSchema = new Schema({
},
})
const User = model(
export interface IUser {
username: string
email: string
hashedPassword: string
socialLogins: Map<string, ISocialLogin>
createdAt: Date
updatedAt: Date
}
export const User = model<IUser>(
'User',
new Schema(
new Schema<IUser>(
{
username: {
type: String,
@@ -42,5 +57,3 @@ const User = model(
}
)
)
export default User