diff options
author | ab <abdullah_ahmed@brown.edu> | 2019-06-19 10:07:45 -0400 |
---|---|---|
committer | ab <abdullah_ahmed@brown.edu> | 2019-06-19 10:07:45 -0400 |
commit | 5959f37c89db0fcafdc2aa94a4aba692960edb54 (patch) | |
tree | 720b7010d2d107770862353a5a6ac0e327eb1c8b /src/new_fields/Doc.ts | |
parent | c2da1676379817fb977a7233fadfb96ab67dc16f (diff) | |
parent | 0674331f3611d297028526c888c718a75b012e0a (diff) |
merged
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 7e02a5bc5..1b0ff812f 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -132,6 +132,16 @@ export class Doc extends RefField { this[fKey] = value; } } + const unset = diff.$unset; + if (unset) { + for (const key in unset) { + if (!key.startsWith("fields.")) { + continue; + } + const fKey = key.substring(7); + delete this[fKey]; + } + } } } @@ -186,7 +196,8 @@ export namespace Doc { } // compare whether documents or their protos match - export function AreProtosEqual(doc: Doc, other: Doc) { + export function AreProtosEqual(doc?: Doc, other?: Doc) { + if (!doc || !other) return false; let r = (doc === other); let r2 = (doc.proto === other); let r3 = (other.proto === doc); |