doc gpt V0.2
This commit is contained in:
40
src/service/models/user.ts
Normal file
40
src/service/models/user.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Schema, model, models } from 'mongoose';
|
||||
import { hashPassword } from '@/service/utils/tools';
|
||||
|
||||
const UserSchema = new Schema({
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true // 唯一
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
set: (val: string) => hashPassword(val),
|
||||
get: (val: string) => hashPassword(val),
|
||||
select: false
|
||||
},
|
||||
balance: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
accounts: [
|
||||
{
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: ['openai'] // 定义允许的type
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
],
|
||||
createTime: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
}
|
||||
});
|
||||
|
||||
export const User = models['user'] || model('user', UserSchema);
|
||||
Reference in New Issue
Block a user