Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxDB 16.6.1 conflict handler deleted field mismatch #6868

Open
troywweber7 opened this issue Feb 15, 2025 · 0 comments
Open

RxDB 16.6.1 conflict handler deleted field mismatch #6868

troywweber7 opened this issue Feb 15, 2025 · 0 comments

Comments

@troywweber7
Copy link

troywweber7 commented Feb 15, 2025

On our project we use deleted for the deleted field on our graphql backend, so that means I have set deletedField: 'deleted' on the replication options. When I write a custom conflict handler to try to merge changes, I was surprised to see a discrepancy.

The types for the conflictHandler.resolve method indicate that the shape of assumedMasterState and newDocumentState is identical to the shape of realMasterState. But at runtime, that does not appear to be true.

Since we are using the deletedField option and changing it, I could just account for this in the handler logic by type-asserting that the assumed state and new state actually have a slightly different shape than the real state. I would just make sure to return a resolution that matches the real state. But I figured I should submit an issue just in case anyone else has run into this.

Here is a snippet of the object I console logged.

{
    "newDocumentState": {
        "id": "9b61cadc-c29f-46d5-934b-ba60063f08ee",
        "updatedAt": 1739581928057,
        "firstName": "A",
        "lastName": "Second",
        "companyName": "Second",
        "deleted": true
    },
    "assumedMasterState": {
        "id": "9b61cadc-c29f-46d5-934b-ba60063f08ee",
        "updatedAt": 1739581839714,
        "firstName": "A",
        "lastName": "Second",
        "companyName": "Second",
        "deleted": false
    },
    "realMasterState": {
        "id": "9b61cadc-c29f-46d5-934b-ba60063f08ee",
        "updatedAt": 1739581935975,
        "firstName": "A",
        "lastName": "B",
        "companyName": "Second",
        "_deleted": false
    }
}

The logic would certainly be easier to write/understand if the same field was used at runtime for every entry in the RxConflictHandlerInput<Item>. So is this behaving as expected already? If not, should the values in RxConflictHandlerInput<Item> all have the user configured deleted or the internal RxDB _deleted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant