Updating MongoDB with changesetArray

I'm right now trying to create a feature where users can edit the table, and the table will sync that with MongoDB.

To my understanding changes in table are stored in changesetArray as described in Using changesetArray with MongoDB to store updates.

However, I'm not too sure how to 1) create the query to sync information in changesetArray with MongoDB 2) run the query automatically when information is updated.

Would appreciate any tips/guidance.

Edit1: I've realized changesetArray is an object of table, but when I do {{ table2.changeSet }} it returns Update document requires atomic operators. To my knowledge though, based on the previous referenced retool link, it's sufficient to pass in table2.changeSet?

here is docs of configure mongodb and bulk upsert using a primary key

changeSet is included in legency table not new table component. In new table you should use changesetArray or changesetObject

You can add a event handler to the query of upsert in which you can write some code to reload the updated datasource or to reset the table