MCPcopy Index your code
hub / github.com/TanStack/db / deleteProperty

Function deleteProperty

packages/db/src/proxy.ts:1024–1066  ·  view source on GitHub ↗
(dobj, prop)

Source from the content-addressed store, hash-verified

1022 },
1023
1024 deleteProperty(dobj, prop) {
1025 debugLog(`deleteProperty`, dobj, prop)
1026 const stringProp = typeof prop === `symbol` ? prop.toString() : prop
1027
1028 if (stringProp in dobj) {
1029 // Check if the property exists in the original object
1030 const hadPropertyInOriginal =
1031 stringProp in changeTracker.originalObject
1032
1033 // Forward the delete to the target using Reflect
1034 // This respects Object.seal/preventExtensions constraints
1035 const result = Reflect.deleteProperty(dobj, prop)
1036
1037 if (result) {
1038 // If the property didn't exist in the original object, removing it
1039 // should revert to the original state
1040 if (!hadPropertyInOriginal) {
1041 delete changeTracker.assigned_[stringProp]
1042
1043 // If this is the last change and we're not a nested object,
1044 // mark the object as unmodified
1045 if (
1046 Object.keys(changeTracker.assigned_).length === 0 &&
1047 Object.getOwnPropertySymbols(changeTracker.assigned_).length ===
1048 0
1049 ) {
1050 changeTracker.modified = false
1051 } else {
1052 // We still have changes, keep as modified
1053 changeTracker.modified = true
1054 }
1055 } else {
1056 // Mark this property as deleted
1057 changeTracker.assigned_[stringProp] = false
1058 markChanged(changeTracker)
1059 }
1060 }
1061
1062 return result
1063 }
1064
1065 return true
1066 },
1067 })
1068
1069 // Cache the proxy

Callers

nothing calls this directly

Calls 4

debugLogFunction · 0.85
markChangedFunction · 0.85
toStringMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…