Files
Foundry-VTT-Docker/resources/app/dist/database/backend/embedded-delta.mjs

1 line
733 B
JavaScript
Raw Normal View History

2025-01-04 00:34:03 +01:00
export default function EmbeddedDeltaMixin(e){return class extends e{async _preUpdate(e,t,s){if(!1===await super._preUpdate(e,t,s))return!1;const i=this.parent.getEmbeddedCollection(this.parentCollection);i.manages(this.id)||i.set(this.id,this)}batchWrite(e,{restoreDelta:t=!1,...s}={}){const i=this.parent.getEmbeddedCollection(this.parentCollection);t&&!i.manages(this.id)?super.batchDelete(e):super.batchWrite(e,s)}batchDelete(e,{restoreDelta:t=!1}={}){const s=this.parent.getEmbeddedCollection(this.parentCollection);if(!t&&s.isTombstone(this.id)){const t=new foundry.data.TombstoneData({_id:this.id}),{dbKey:s,sublevelName:i}=this;this.constructor.batchWrite(t.toObject(),e,{dbKey:s,sublevelName:i})}else super.batchDelete(e)}}}