diff options
Diffstat (limited to 'src/new_fields')
| -rw-r--r-- | src/new_fields/Doc.ts | 12 | 
1 files changed, 11 insertions, 1 deletions
| diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 625ba0d6a..a8c9d28e1 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -134,7 +134,8 @@ export namespace Doc {          return Cast(Get(doc, key, ignoreProto), ctor) as FieldResult<T>;      }      export async function SetOnPrototype(doc: Doc, key: string, value: Field) { -        const proto = doc.proto; +        const proto = Object.getOwnPropertyNames(doc).indexOf("isProto") == -1 ? doc.proto : doc; +          if (proto) {              proto[key] = value;          } @@ -160,6 +161,15 @@ export namespace Doc {          return doc;      } +    // compare whether documents or their protos match +    export function AreProtosEqual(doc: Doc, other: Doc) { +        let r = (doc[Id] === other[Id]); +        let r2 = (doc.proto && doc.proto.Id === other[Id]); +        let r3 = (other.proto && other.proto.Id === doc[Id]); +        let r4 = (doc.proto && other.proto && doc.proto[Id] === other.proto[Id]); +        return r || r2 || r3 || r4 ? true : false; +    } +      export function MakeAlias(doc: Doc) {          const alias = new Doc; | 
