Tracking of changes in collection

In documentation we see.


What is it? - Returns an Observable of the most recent changes as a DocumentChangeAction[].

In code we see

Listen to the latest change in the stream. This method returns changes as they occur and they are not sorted by query order. This allows you to construct your own data structure.

in reality


Console says:

0: {type: "added", payload: {…}}
1: {type: "added", payload: {…}}
2: {type: "added", payload: {…}}
3: {type: "added", payload: {…}}
4: {type: "added", payload: {…}}

we see that all changes from all history were logged.

Is there way to observe only changes from moment I started to observe?

Is it bug or intended behaviour?

1 answer

  • answered 2019-10-15 16:34 Doug Stevenson

    This is working as expected. Your code is querying for every document in the collection identified by entity.path, so you can expect to receive every document in the initial set of results. If you don't want all the documents in the collection, you will need to come up with a "where" clause filter that identifies which documents you do want. If your interest is based on the time of the query, consider adding a timestamp field to each document so you can use it in a filter that will give you only documents that will appear after the current moment in time.