Hi there,
I have an issue with watch() function fo realm web sdk collections.
When I insert a new document in the collection, the change event get trapped and I make a
collection.find() to update the list of document. The issue is that the newly created document
is not present in the find() result.
I think that the issue is related to Atlas cluster default read and write concerns…
i have a mongodb 5.0 cluster M10 and the default readConcern is local while the
default write concern is majority. I was unable to modify the default readConcern and
I have not found anything about specifyng readConcern during find() operation (web sdk).
here is a snippet of code to clarify what I’m tryng to do:
private async initWatcher() {
if (this.debug) console.log("[SiteService] - initWatcher - checking existent watcher...");
// closing the existing watcher to avoid memory leaks
if (this.watcher) this.watcher.return(undefined);
if (this.debug) console.log("[SiteService] - initWatcher - defining new watcher...");
// creating the new watcher
this.watcher = this._sitesCollection.watch();
// listening for changes
for await (const change of this.watcher) {
if (this.debug) console.log("[SiteService] - initWatcher - watch operationType: ", change.operationType);
await this.fetchSites();
await this.fetchDashboardSites();
}
}