Files
ZYZ/game-server/app/db/User.ts

45 lines
863 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import BaseModel from './BaseModel';
import { index, getModelForClass, prop } from '@typegoose/typegoose';
/**
* 用户字段接口
*/
@index({ userNo: 1 })
export default class User extends BaseModel {
@prop({ required: true})
userNo: number;
@prop({ required: true})
userName: string;
@prop({ required: true})
token: string;
@prop({ required: true})
telHash: string;
//#region实例方法 和 实例方法)
public async userInstanceTestMethods() {
const user: User = new User();
user.userName = '我是实例化方法测试';
user.userNo = 9527;
return user;
}
public static async userStaticTestMethods() {
const user: User = new User();
user.userName = '我是静态方法测试';
user.userNo = 9527;
return user;
}
//#endregion
}
export const UserModel = getModelForClass(User);