Skip to content

Issue with soft-delete package #25

@harry-73

Description

@harry-73

Hi,

I have a .once publication, I subscribe to it and I have a method which call removeAsync.
So the document is soft deleted on server side but not changed message is sent to the client.

looking at the mongo.js code, in the updateAsync (at the end updateAsync is called as it is soft delete so we update the deleted field to true ) part :

 const finalFilter = hasId ? filter : insertedId ? { _id: insertedId } : docIds ? {_id: numberAffected === 1 ? docIds[0] : { $in: docIds }} : undefined;
 const { projection, unsets = [] } = finalFilter && createProjection(modifier);
const items = finalFilter ? await this.find(finalFilter, { projection }).fetchAsync() : [];

with finalFilter = { _id: ObjectID { _str: '6a1a43125abc95913356c0c7' }
and projection = { deleted: 1, deletedAt: 1, updatedAt: 1 }

items, at the end, is equal to [] so no changed message sent

If I modify for testing pupose finalFilter to { _id: ObjectID { _str: '6a1a43125abc95913356c0c7', deleted: true }
items is not empty ans the changed message is correctly sent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions