Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How can i performe a Soft Delete using CollectionAfterDeleteHook?

default discord avatar
kurosteinlast year
1

i need to change an attribute archived when my object is deleted, there are any ways to stop my DeleteHook from processing the delete itself?

  • default discord avatar
    thgh.2 weeks ago

    what was the solution? beforeDelete?



        beforeDelete: [
          async ({ req, id }) => {
            await req.payload.db.collections.messages.updateOne(
              { _id: id },
              { $set: { status: 'deleted' } },
            )
            throw new APIError('Soft-delete', 200)
          },
        ],
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.