Skip to main content

Document Service API: Triggered database lifecycle hooks

Depending on the Document Service API methods called, the following database lifecycle hooks are triggered:

Document Service API methodTriggered database lifecycle hook(s)
findOne()before(after) findOne
findFirst()before(after) findOne
findMany()before(after) findMany
create()before(after) Create
create({ status: 'published' })
  • before(after) Create️
    Triggered twice as it creates both the draft and published versions
  • before(after) Delete
    • Deletes previous draft versions of a document
    • Can be triggered multiple times if deleting multiple locales (one per each locale)
update()
  • before(after) Create
    when creating a new locale on a document
  • before(after) Update
    when updating an existing version of a document
update({ status: 'published' })
  • before(after) Create
    Can be triggered multiple times if deleting multiple locales (one per each locale)
  • before(after) Update
    when updating an existing version of a document
  • before(after) Delete
    • Deletes previous published versions of a document
    • Can be triggered multiple times if deleting multiple locales (one per each locale)
delete()before(after) Delete
Can be triggered multiple times if deleting multiple locales (one per each locale)
publish()
  • before(after) Create
    Can be triggered multiple times if deleting multiple locales (one per each locale)
  • before(after) Delete
    • Deletes previous published versions of a document
    • Can be triggered multiple times if deleting multiple locales (one per each locale)
unpublish()before(after) Delete
  • Deletes all published versions of a document
  • Can be triggered multiple times if deleting multiple locales (one per each locale)
discardDraft()
  • before(after) Create
    • Creates new draft versions
    • Can be triggered multiple times if deleting multiple locales (one per each locale)
  • before(after) Delete
    • Deletes previous draft versions of a document
    • Can be triggered multiple times if deleting multiple locales (one per each locale)
count()before(after) Count
✏️ Note

Bulk actions lifecycles (createMany, updateMany, deleteMany) will never be triggered by a Document Service API method.