version log index

pull/2427/head
withchao 1 year ago
parent f8394d4fd8
commit 187903e3c3

@ -18,8 +18,8 @@ import (
func NewVersionLog(coll *mongo.Collection) (database.VersionLog, error) { func NewVersionLog(coll *mongo.Collection) (database.VersionLog, error) {
lm := &VersionLogMgo{coll: coll} lm := &VersionLogMgo{coll: coll}
if lm.initIndex(context.Background()) != nil { if err := lm.initIndex(context.Background()); err != nil {
return nil, errs.ErrInternalServer.WrapMsg("init index failed", "coll", coll.Name()) return nil, errs.WrapMsg(err, "init version log index failed", "coll", coll.Name())
} }
return lm, nil return lm, nil
} }
@ -33,6 +33,7 @@ func (l *VersionLogMgo) initIndex(ctx context.Context) error {
Keys: bson.M{ Keys: bson.M{
"d_id": 1, "d_id": 1,
}, },
Options: options.Index().SetUnique(true),
}) })
return err return err
} }

Loading…
Cancel
Save