import { Schema, Document } from 'mongoose' import db from '../service/db' import { DbCollection } from '../types' export interface IUUserModel extends Document, DbCollection.User { _id: string name: string email: string } const user = new Schema({ // 自定义id, 不可变 username: { type: String, maxlength: 100, default: '' }, name: String }) export const UserModel = db.model('User', user)