()
| 20 | // promise and force an extra microtask hop on every `save()` when there are |
| 21 | // no subdocuments. kareem only awaits hooks that return a promise. |
| 22 | function saveSubdocsPreSave() { |
| 23 | if (this.$isSubdocument) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | const subdocs = this.$getAllSubdocs({ useCache: true }); |
| 28 | |
| 29 | if (!subdocs.length) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | const options = this.$__.saveOptions; |
| 34 | return Promise.all(subdocs.map(subdoc => subdoc._execDocumentPreHooks('save', options, [options]))).then(() => { |
| 35 | // Invalidate subdocs cache because subdoc pre hooks can add new subdocuments |
| 36 | if (this.$__.saveOptions) { |
| 37 | this.$__.saveOptions.__subdocs = null; |
| 38 | } |
| 39 | }); |
| 40 | } |
| 41 | |
| 42 | function saveSubdocsPostSave() { |
| 43 | if (this.$isSubdocument) { |
nothing calls this directly
no outgoing calls
no test coverage detected