Skip to content

Commit

Permalink
fix bug with watcher not setting resume token
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-nitehawk committed Jul 30, 2020
1 parent 35bb0eb commit b6cc6c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
12 changes: 8 additions & 4 deletions MongoDB.Entities/Commands/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Watcher<T> where T : IEntity
/// <summary>
/// The last resume token received from mongodb server. Can be used to resume watching with .StartWithToken() method.
/// </summary>
public BsonDocument ResumeToken => options?.ResumeAfter;
public BsonDocument ResumeToken => options?.StartAfter;

private PipelineDefinition<ChangeStreamDocument<T>, ChangeStreamDocument<T>> pipeline;
private ChangeStreamOptions options;
Expand All @@ -63,7 +63,7 @@ public class Watcher<T> where T : IEntity
/// <param name="filter">x => x.FullDocument.Prop1 == "SomeValue"</param>
/// <param name="batchSize">The max number of entities to receive for a single event occurence</param>
/// <param name="onlyGetIDs">Set to true if you don't want the complete entity details. All properties except the ID will then be null.</param>
/// <param name="autoResume">Set to false if you'd like to skip the changes that happened while the watching was stopped</param>
/// <param name="autoResume">Set to false if you'd like to skip the changes that happened while the watching was stopped. This will also make you unable to retrieve a ResumeToken.</param>
/// <param name="cancellation">A cancellation token for ending the watching/change stream</param>
public void Start(
EventType eventTypes,
Expand Down Expand Up @@ -138,8 +138,12 @@ private void Init(

PipelineStageDefinitionBuilder.Match(filters),

PipelineStageDefinitionBuilder.Project<ChangeStreamDocument<T>,ChangeStreamDocument<T>>(
$"{{ _id: 1, operationType: 1 , fullDocument: {(onlyGetIDs ? "'$documentKey'" : "1")} }}")
PipelineStageDefinitionBuilder.Project<ChangeStreamDocument<T>,ChangeStreamDocument<T>>(@"
{
_id: 1,
operationType: 1,
fullDocument: { $ifNull: ['$fullDocument', '$documentKey'] }
}")
};

options = new ChangeStreamOptions
Expand Down
12 changes: 5 additions & 7 deletions MongoDB.Entities/MongoDB.Entities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
<Description>A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management.</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/dj-nitehawk/MongoDB.Entities</PackageProjectUrl>
<Version>13.6</Version>
<AssemblyVersion>13.6.0.0</AssemblyVersion>
<FileVersion>13.6.0.0</FileVersion>
<Version>13.6.1</Version>
<AssemblyVersion>13.6.1.0</AssemblyVersion>
<FileVersion>13.6.1.0</FileVersion>
<Copyright>Đĵ ΝιΓΞΗΛψΚ</Copyright>
<PackageReleaseNotes>- simplified change-stream api
- ability to resume change-streams with tokens
- ability to filter insert &amp; update events with an expression
- misc. code changes</PackageReleaseNotes>
<PackageReleaseNotes>- fix bug with change-stream watcher not setting resume token correctly
- improve change-stream watcher internal pipeline</PackageReleaseNotes>
<PackageId>MongoDB.Entities</PackageId>
<Product>MongoDB.Entities</Product>
<RepositoryUrl></RepositoryUrl>
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ This library simplifies access to mongodb by abstracting away the C# mongodb dri
- Programatically define indexes.
- Full text search (including fuzzy matching) with text indexes.
- Multi-document transaction support.
- Multiple database support.
- Easy bulk operations.
- Update with aggregation pipeline stages & array filters.
- Easy GeoSpatial search.
- Change-stream support.
- GeoSpatial search.
- Stream files in chunks to and from mongodb (GridFS alternative).
- Multiple database support.
- Project types supported: .Net Standard 2.0 (.Net Core 2.0 & .Net Framework 4.6.1 or higher)


Expand Down

0 comments on commit b6cc6c6

Please sign in to comment.