UserLog
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import { Schema, model } from 'mongoose';
|
import { Schema, model } from 'mongoose';
|
||||||
|
|
||||||
|
export type UserIDType = number;
|
||||||
export type validOAuthType = 'KAKAO' | 'NONE';
|
export type validOAuthType = 'KAKAO' | 'NONE';
|
||||||
|
|
||||||
const validOAuthTypeList: validOAuthType[] = ['KAKAO', 'NONE'];
|
const validOAuthTypeList: validOAuthType[] = ['KAKAO', 'NONE'];
|
||||||
|
|
||||||
interface IUser {
|
interface IUser {
|
||||||
_id: number;
|
_id: UserIDType;
|
||||||
|
|
||||||
oauthID?: bigint;
|
oauthID?: bigint;
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -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);
|
||||||
Reference in New Issue
Block a user