【发布时间】:2022-08-22 19:47:23
【问题描述】:
我遇到了一种情况,我的 MongoDB 有一个存储为字符串的字段,我需要确保该字段只有特定的枚举值。 同样,我应该只收到具有相同枚举的请求,并且应该能够将该结构变量作为枚举无处不在。
type studentModel struct {
studentType enums.StudentType `bson:\"studentType, omitempty\" json:\"studentType,omitempty\"`
studentId int64 `bson:\"studentId, omitempty\" json:\"studentId,omitempty\"`
}
studentType Enum Values : PAID , UNPAID , INACTIVE