table.go 793 B

123456789101112131415161718192021222324252627282930313233
  1. package dbFacade
  2. import (
  3. "go.mongodb.org/mongo-driver/v2/mongo"
  4. )
  5. type Table interface {
  6. TableName() string // 表名
  7. PrimaryValue() any // !!!这是主键值,必需是单表唯一,不行就用唯一ID
  8. EnableQueue() bool // 是否启动保存队列
  9. FlushUpdateTime(now int64) // 刷新更新时间
  10. CheckField() // 初始化或保存时检查字段空值
  11. Indexes() []mongo.IndexModel // 构建索引列表
  12. }
  13. type TableBase struct {
  14. UpdateTime int64 `bson:"UpdateTime,omitempty"` // 更新时间
  15. }
  16. func (p *TableBase) FlushUpdateTime(now int64) {
  17. p.UpdateTime = now
  18. }
  19. func (p *TableBase) EnableQueue() bool {
  20. return true
  21. }
  22. func (p *TableBase) CheckField() {
  23. }
  24. func (p *TableBase) Indexes() []mongo.IndexModel {
  25. return nil
  26. }