(session)
| 770 | * If transaction was aborted, we need to reset newly inserted documents' `isNew`. |
| 771 | */ |
| 772 | function _resetSessionDocuments(session) { |
| 773 | for (const doc of session[sessionNewDocuments].keys()) { |
| 774 | const state = session[sessionNewDocuments].get(doc); |
| 775 | if (Object.hasOwn(state, 'isNew')) { |
| 776 | doc.$isNew = state.isNew; |
| 777 | } |
| 778 | if (Object.hasOwn(state, 'versionKey')) { |
| 779 | doc.set(doc.schema.options.versionKey, state.versionKey); |
| 780 | } |
| 781 | |
| 782 | if (state.modifiedPaths.length > 0 && doc.$__.activePaths.states.modify == null) { |
| 783 | doc.$__.activePaths.states.modify = {}; |
| 784 | } |
| 785 | for (const path of state.modifiedPaths) { |
| 786 | const currentState = doc.$__.activePaths.paths[path]; |
| 787 | if (currentState != null) { |
| 788 | delete doc.$__.activePaths[currentState][path]; |
| 789 | } |
| 790 | doc.$__.activePaths.paths[path] = 'modify'; |
| 791 | doc.$__.activePaths.states.modify[path] = true; |
| 792 | } |
| 793 | |
| 794 | for (const path of state.atomics.keys()) { |
| 795 | const val = doc.$__getValue(path); |
| 796 | if (val == null) { |
| 797 | continue; |
| 798 | } |
| 799 | val[arrayAtomicsSymbol] = state.atomics.get(path); |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | /** |
| 805 | * Helper for `dropCollection()`. Will delete the given collection, including |
no test coverage detected
searching dependent graphs…