You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/server/models/user/userLoginLog.ts

56 lines
997 B
TypeScript

import {
getModelForClass,
prop,
DocumentType,
Ref,
modelOptions,
Severity,
index,
} from '@typegoose/typegoose';
import { Base, TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
import type { Types } from 'mongoose';
import { User } from './user';
@modelOptions({
options: {
allowMixed: Severity.ALLOW,
},
schemaOptions: {
collection: 'user_login_logs',
},
})
@index({ userId: 1, createdAt: -1 })
@index({ ip: 1, createdAt: -1 })
export class UserLoginLog extends TimeStamps implements Base {
_id: Types.ObjectId;
id: string;
/**
*
*/
@prop({ ref: () => User, required: true })
userId: Ref<User>;
/**
* IP
*/
@prop({
required: true,
})
ip: string;
/**
* User-Agent
*/
@prop()
userAgent?: string;
}
export type UserLoginLogDocument = DocumentType<UserLoginLog>;
const model = getModelForClass(UserLoginLog);
export type UserLoginLogModel = typeof model;
export default model;