This commit is contained in:
2023-08-18 14:49:45 +00:00
parent 0fda257ca0
commit 17977b4d96
2 changed files with 33 additions and 1 deletions
+3 -1
View File
@@ -1,10 +1,12 @@
import { Schema, model } from 'mongoose';
export type UserIDType = number;
export type validOAuthType = 'KAKAO' | 'NONE';
const validOAuthTypeList: validOAuthType[] = ['KAKAO', 'NONE'];
interface IUser {
_id: number;
_id: UserIDType;
oauthID?: bigint;
id: string;
+30
View File
@@ -0,0 +1,30 @@
import { Schema, model, } from 'mongoose';
import { type UserIDType } from './User.js';
export type LogType = 'register'
| 'login_pw' | 'login_token' | 'login_oauth' | 'logout'
| 'change_pw' | 'reset_pw';
const LogTypeList: LogType[] = [
'register',
'login_pw', 'login_token', 'login_oauth', 'logout',
'change_pw', 'reset_pw',
];
interface IUserLog {
userID: UserIDType;
logDate: Date;
logType: LogType;
action: object;
}
export const UserLog = new Schema<IUserLog>({
userID: { type: Number, required: true },
logDate: { type: Date, required: true },
logType: { type: String, required: true, enum: LogTypeList },
action: { type: Object, required: true },
})
.index({ userID: 1, logDate: 1 })
.index({ logDate: 1 })
;
export default model<IUserLog>('UserLog', UserLog);