mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00
4.6.7 first pr (#726)
This commit is contained in:
55
packages/service/support/wallet/sub/schema.ts
Normal file
55
packages/service/support/wallet/sub/schema.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { connectionMongo, type Model } from '../../../common/mongo';
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant';
|
||||
import { subModeMap, subStatusMap, subTypeMap } from '@fastgpt/global/support/wallet/sub/constants';
|
||||
import type { TeamSubSchema } from '@fastgpt/global/support/wallet/sub/type';
|
||||
|
||||
export const subCollectionName = 'team.subscription';
|
||||
|
||||
const SubSchema = new Schema({
|
||||
teamId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: TeamCollectionName,
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
enum: Object.keys(subTypeMap),
|
||||
required: true
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
enum: Object.keys(subModeMap),
|
||||
required: true
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
enum: Object.keys(subStatusMap),
|
||||
required: true
|
||||
},
|
||||
renew: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
startTime: {
|
||||
type: Date
|
||||
},
|
||||
expiredTime: {
|
||||
type: Date
|
||||
},
|
||||
datasetStoreAmount: {
|
||||
type: Number
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
SubSchema.index({ teamId: 1 });
|
||||
SubSchema.index({ status: 1 });
|
||||
SubSchema.index({ type: 1 });
|
||||
SubSchema.index({ expiredTime: -1 });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
export const MongoTeamSub: Model<TeamSubSchema> =
|
||||
models[subCollectionName] || model(subCollectionName, SubSchema);
|
Reference in New Issue
Block a user