Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Created by Guest
Created on Jul 5, 2022

Generic count property in _WriteResult class

Hi, I'm using a MongoDB as a backend for my API and often come to a case where i want to validate whether I updated, inserted or deleted any records. At the moment I use the deleted_count and machted_count properties in the DeleteResult and UpdateResult object. To provide a more generic way I thought it may makes sense to provide a new property in the generic _WriteResult class called affected_records or something like that so you can generic react to the result of your database transaction and maybe return a 404 if nothing was updated, deleted or created. Let me know what you think and thanks in advance.