Skip to content

Commit

Permalink
update selector
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 13, 2023
1 parent 793562a commit 05564f1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,18 @@ func (m *Migration) blockUntilDBReady() error {
func (m *Migration) fetchAndUpdateBatch() bool {
selector := bson.M{
// jellyfish uses a generated _id that is not an mongo objectId
"_id": bson.M{"$not": bson.M{"$type": "objectId"}},
"_deduplicator": bson.M{"$exists": false},
// testing based on _userId for [email protected]
"_userId": "5e8cac61-6bef-4728-b490-c1d82087ed9c",
}

if m.lastUpdatedId != "" {
selector["_id"] = bson.M{"$and": []interface{}{
bson.M{"$gt": m.lastUpdatedId},
bson.M{"$type": "objectId"},
}}
log.Printf("selector with _id $gt %#v", selector)
selector["$and"] = []interface{}{
bson.M{"_id": bson.M{"$gt": m.lastUpdatedId}},
bson.M{"_id": bson.M{"$not": bson.M{"$type": "objectId"}}},
}
} else {
selector["_id"] = bson.M{"$not": bson.M{"$type": "objectId"}}
}

m.updates = []mongo.WriteModel{}
Expand Down

0 comments on commit 05564f1

Please sign in to comment.