realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.78k stars 573 forks source link

realm-web's `findOneAndDelete` leaves empty document with only _id in collection #6497

Open arfath-linklet opened 7 months ago

arfath-linklet commented 7 months ago

How frequently does the bug occur?

Always

Description

When using realm-web's findOneAndDelete it leaves an empty document with only _id in the collection

image

findOneAndDelete appears to be using findOneAndReplace under the hood. This issue appears to be related to another issue from realm-js - https://github.com/realm/realm-js/issues/5151

Current workaround is to use find and delete as separate operations.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

realm-web@2.0.0

What services are you using?

Atlas App Services: Functions or GraphQL or DataAPI etc

Are you using encryption?

Yes

Platform OS and version(s)

Browser

Build environment

No response

Cocoapods version

No response

sync-by-unito[bot] commented 7 months ago

➤ PM Bot commented:

Jira ticket: RJS-2737

nirinchev commented 7 months ago

This is a legitimate bug - looks like we've got a copy-paste error here: https://github.com/realm/realm-js/blob/1e1e48a0f906d471b4a046168ed8cd628ef2d70f/packages/realm-web/src/services/MongoDBService/MongoDBCollection.ts#L134-L145