mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
add types to models
This commit is contained in:
1 parent
5489de2432
commit
9dc0b43737
16 files changed
+179
-73
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user