INNER CODE UNIT · Go
FirstOpTimestamp
rwynn/gtm · gtm.go:968
func FirstOpTimestamp(client *mongo.Client, o *Options) (primitive.Timestamp, error) {
opLog := OpLog{}
filter := validOps()
opts := &options.FindOneOptions{}
opts.SetSort(bson.M{"$natural": 1})
c := OpLogCollection(client, o)
err := c.FindOne(context.Background(), filter, opts).Decode(&opLog)
return opLog.Timestamp, err
}
func GetOpLogCursor(client *mongo.Client, after primitive.Timestamp, o *Options) (*mongo.Cursor, error) {
query := bson.M{
"ts": bson.M{"$gt": after},
"op": bson.M{"$in": opCodes},
"fromMigrate": bson.M{"$exists": false},
}
opts := &options.FindOptions{}
opts.SetSort(bson.M{"$natural": 1})