Reputation: 183
I'm aware of mongo's resume token, and StartAtOperationTime, and startafter, but I'd like to do something a little different.
I want to query and watch for a document, where the stream begins at the current snapshot of the document. The client knows nothing else about when it was written.
Using the go client, I'd like to:
stream, err := r.collection.Watch(ctx, mongo.Pipeline{
{{"$match", bson.D{{"short_id", id}}}},
}
Is this possible? One option would be to query for the entity first if it could expose what its most recent position in the oplog is
Upvotes: 0
Views: 198
Reputation: 14520
Change streams allow providing filtering conditions.
Filtering conditions influence what change events are sent to the particular change stream, they do not influence the change stream's starting point.
To adjust the starting point, use one of the resume methods you mentioned.
Upvotes: 1