New user trying to use pipedream to update existing data

Hello all! I am a very new user to mongodb and am managing my DB using compass. I am using pipedream to port data over from an API. This works fine and my data shows up in mongodb.

However, the API will always send the latest amount of XP that a user has. How do I make it so each user (determined by the input “user”) will have a single DB entry and when new data is brought in (new xp amounts and level) that that db entry will be updated with the latest. Thank you,

Hello @Park_Dalton, welcome to the MongoDB community forum.

Here is a way you can think about.

The data coming thru the pipedream can be inserted into a staging collection - this is an in-between or an intermediate collection. Then, define a Change Stream on this staging collection.

The change stream can subscribe to a data change event (i.e., document insert) and do this further: The collection where your original data is there is checked for the “user”, and update the document with the latest data from the staging collection.