From d3dd12a54700fb20aaf41e60868cb548b42b0efc Mon Sep 17 00:00:00 2001 From: wancat Date: Sat, 14 Oct 2023 15:42:39 +0800 Subject: [PATCH] feat: add Timestamps to User model --- packages/models/user.js | 52 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/packages/models/user.js b/packages/models/user.js index 3280c3e..6c3bc44 100644 --- a/packages/models/user.js +++ b/packages/models/user.js @@ -1,25 +1,33 @@ -import { model } from 'mongoose' +import { model, Schema } from 'mongoose' -const User = model('User', { - username: { - type: String, - unique: true, - required: true, - }, - email: { - type: String, - unique: true, - required: true, - }, - hashedPassword: String, - google: { - id: String, - displayName: String, - }, - github: { - id: String, - displayName: String, - }, -}) +const User = model( + 'User', + new Schema( + { + username: { + type: String, + unique: true, + required: true, + }, + email: { + type: String, + unique: true, + required: true, + }, + hashedPassword: String, + google: { + id: String, + displayName: String, + }, + github: { + id: String, + displayName: String, + }, + }, + { + timestamps: true, + } + ) +) export default User