From 8946393cee476e4572d03411d162c68e7ecd7899 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Mon, 10 May 2021 09:20:17 -0400 Subject: [PATCH 01/12] (DOCSP-14565): Dictionary Data Type - Node.js --- source/sdk/node/data-types/dictionaries.txt | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index b0dc026ce2..2cb7da0910 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -15,4 +15,29 @@ Dictionaries - Node.js SDK .. versionadded:: 10.5.0-beta.1 Overview --------- \ No newline at end of file +-------- +You can use the ``dictionary`` data type to manage a collection of unique String +keys paired with values. The ``dictionary`` data maps to the Javascript +:mdn:`Object ` type. + +Realm Object Models +------------------- + + +Create a Dictionary +------------------- + +Update a Dictionary +------------------- +Update an Existing Field of a Dictionary +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Add a New Field to a Dictionary +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Delete Members of a Dictionary +------------------------------ + +Query for Objects with a Dictionary Property +-------------------------------------------- + + From 73dc17775b2876ba65e7cb4dfa3096b4e04940ce Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Mon, 10 May 2021 16:18:20 -0400 Subject: [PATCH 02/12] added unit tested + bluehawked dictionary examples --- examples/node/Examples/data-types.js | 137 +++- examples/node/package-lock.json | 605 ++++++++++-------- examples/node/package.json | 4 +- ...odeblock.add-a-listener-to-a-dictionary.js | 9 + ...eblock.create-realm-obj-with-dictionary.js | 13 + ...s.codeblock.define-dictionary-in-schema.js | 7 + ...data-types.codeblock.query-a-dictionary.js | 15 + ...deblock.remove-fields-of-the-dictionary.js | 4 + ...a-types.codeblock.set-additional-fields.js | 4 + ...ng-new-dictionaries-to-existing-objects.js | 14 + ...ata-types.codeblock.update-a-dictionary.js | 7 + source/sdk/node/data-types/dictionaries.txt | 36 +- 12 files changed, 598 insertions(+), 257 deletions(-) create mode 100644 source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js create mode 100644 source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js create mode 100644 source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js create mode 100644 source/examples/generated/node/data-types.codeblock.query-a-dictionary.js create mode 100644 source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js create mode 100644 source/examples/generated/node/data-types.codeblock.set-additional-fields.js create mode 100644 source/examples/generated/node/data-types.codeblock.setting-new-dictionaries-to-existing-objects.js create mode 100644 source/examples/generated/node/data-types.codeblock.update-a-dictionary.js diff --git a/examples/node/Examples/data-types.js b/examples/node/Examples/data-types.js index dd899119fe..fa57abceb9 100644 --- a/examples/node/Examples/data-types.js +++ b/examples/node/Examples/data-types.js @@ -1,4 +1,139 @@ import Realm from "realm"; describe("Node.js Data Types", () => { -}) \ No newline at end of file + test("should create, update and query Realm dictionaries", async () => { + // :code-block-start: define-dictionary-in-schema + const CitySchema = { + name: "City", + properties: { + name: "string", + home: "{}", + }, + }; + // :code-block-end: + + const realm = await Realm.open({ + schema: [CitySchema], + }); + + // :code-block-start: create-realm-obj-with-dictionary + let sanDiegoCity; + realm.write(() => { + sanDiegoCity = realm.create("City", { + name: "san diego", + home: { + windows: 5, + doors: 3, + floor: 1, + color: "red", + address: "Summerhill St.", + }, + }); + }); + // :code-block-end: + + // :code-block-start: query-a-dictionary + // find all houses in san diego + const housesInSanDiego = realm + .objects("City") + .filtered("name = 'san diego'"); + // filtered for a house with the address Summerhill St. + const summerHillHouse = housesInSanDiego.filtered( + `home['address'] = "Summerhill St."` + )[0]; + + // Find all houses that has windows as a key. + const housesWithWindows = housesInSanDiego.filtered( + `home.@keys = "windows" ` + ); + // find all houses that has any field with a value of 'red' + const redHouses = housesInSanDiego.filtered(`home.@values = "red" `); + // :code-block-end: + + // the following assertion tests both creation of a dictionary + querying a dictionary + expect(housesInSanDiego[0].home.windows).toBe(5); // there should be 5 windows in the houses in san diego + + let dictionaryListenerHasBeenCalled = false; + // :code-block-start: add-a-listener-to-a-dictionary + summerHillHouse.addListener((changedHouse, changes) => { + // :hide-start: + dictionaryListenerHasBeenCalled = true; + // :hide-end: + console.log( + `The following changes have occurred in the home: ${JSON.stringify( + changes, + null, + 2 + )}` + ); + }); + // :code-block-end: + + // :code-block-start: update-a-dictionary + // update an existing home, from an existing city in the database + realm.write(() => { + // use the `put()` method to add a field to a dictionary property + summerHillHouse.home.put({ style: "Victorian" }); + // alternatively, set a field of a dictionary through dot notation + summerHillHouse.color = "brown"; + }); + // :code-block-end: + + expect(dictionaryListenerHasBeenCalled).toBe(true); // a home (dictionary inside a realm object) should be able to have a change listener + expect(summerHillHouse.home.style).toBe("Victorian"); // the summerHillHouse should be a Victorian style house + + let queensCity, yakimaCity; + realm.write(() => { + queensCity = realm.create("City", { + name: "Richmond Hill, Queens, NY", + }); + yakimaCity = realm.create("City", { + name: "Yakima, Washington", + }); + }); + + // :code-block-start: setting-new-dictionaries-to-existing-objects + let newVictorianHome; + realm.write(() => { + newVictorianHome = { + doors: 4, + floor: 3, + color: "white", + address: "Trailwoods Rd.", + }; + // use the `put()` method to add a dictionary to a pre-existing city in the database + summerHillHouse.home.put(newVictorianHome); + + // alternatively, use dot notation to add a dictionary to a pre-existing city + yakimaCity.home = newVictorianHome; + }); + // :code-block-end: + + // :code-block-start: set-additional-fields + // use the `put()` method to set a new field, yearBuilt, to the yakimaCity home + yakimaCity.home.put({ yearBuilt: 1993 }); + // alternatively, use dot notation to add a new field, price, to the yakimaCity home + yakimaCity.home.price = 512400; + // :code-block-end: + + expect(yakimaCity.home.color).toBe("white"); // yakimaCity's home should be updated with the newVictorianHome 'white' color + + // :code-block-start: remove-fields-of-the-dictionary + realm.write(() => { + // remove the 'color' and 'floors' field of the Yakima City Victorian Home + yakimaCity.home.remove(["color", "floor"]); + }); + // :code-block-end: + + expect(yakimaCity.home.color).toBe(undefined); // since color has been removed as a field, it should be undefined + + // delete the objects to keep the test idempotent + realm.write(() => { + realm.delete(sanDiegoCity); + realm.delete(queensCity); + realm.delete(yakimaCity); + }); + // close the realm to avoid memory leaks + realm.close(); + }); +}); diff --git a/examples/node/package-lock.json b/examples/node/package-lock.json index 5442131d9d..b95a30bfe2 100644 --- a/examples/node/package-lock.json +++ b/examples/node/package-lock.json @@ -1513,11 +1513,6 @@ "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==" }, - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, "abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -1921,6 +1916,36 @@ "tweetnacl": "^0.14.3" } }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2009,6 +2034,15 @@ "unset-value": "^1.0.0" } }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2192,6 +2226,11 @@ "safe-buffer": "~5.1.1" } }, + "cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -2228,18 +2267,11 @@ } }, "cross-fetch": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.6.tgz", - "integrity": "sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", + "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", "requires": { "node-fetch": "2.6.1" - }, - "dependencies": { - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" - } } }, "cross-spawn": { @@ -2315,6 +2347,14 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, + "decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "requires": { + "mimic-response": "^2.0.0" + } + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -2467,24 +2507,6 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, - "encoding": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", - "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", - "requires": { - "iconv-lite": "^0.6.2" - }, - "dependencies": { - "iconv-lite": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz", - "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - } - } - }, "end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -3160,6 +3182,11 @@ } } }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, "expect": { "version": "26.5.3", "resolved": "https://registry.npmjs.org/expect/-/expect-26.5.3.tgz", @@ -3301,6 +3328,11 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fast-safe-stringify": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" + }, "fastq": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz", @@ -3345,6 +3377,11 @@ "flat-cache": "^2.0.1" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -3429,6 +3466,11 @@ "mime-types": "^2.1.12" } }, + "formidable": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz", + "integrity": "sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q==" + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -3437,6 +3479,11 @@ "map-cache": "^0.2.2" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs-extra": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", @@ -3448,11 +3495,11 @@ } }, "fs-minipass": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", - "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", "requires": { - "minipass": "^2.6.0" + "minipass": "^3.0.0" } }, "fs.realpath": { @@ -3535,6 +3582,16 @@ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, "get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -3566,6 +3623,11 @@ "assert-plus": "^1.0.0" } }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" + }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -3613,7 +3675,8 @@ "growly": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", - "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=" + "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", + "optional": true }, "har-schema": { "version": "2.0.0", @@ -3759,9 +3822,9 @@ }, "dependencies": { "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "requires": { "ms": "^2.1.1" } @@ -3791,14 +3854,6 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" }, - "ignore-walk": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz", - "integrity": "sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw==", - "requires": { - "minimatch": "^3.0.4" - } - }, "import-fresh": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", @@ -3846,9 +3901,9 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", - "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==" + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, "invariant": { "version": "2.2.4", @@ -4077,6 +4132,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "optional": true, "requires": { "is-docker": "^2.0.0" } @@ -5087,6 +5143,11 @@ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, "micromatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", @@ -5096,6 +5157,11 @@ "picomatch": "^2.0.5" } }, + "mime": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==" + }, "mime-db": { "version": "1.44.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", @@ -5114,6 +5180,11 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" }, + "mimic-response": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -5128,20 +5199,20 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "minipass": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", - "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", + "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" + "yallist": "^4.0.0" } }, "minizlib": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", - "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", "requires": { - "minipass": "^2.9.0" + "minipass": "^3.0.0", + "yallist": "^4.0.0" } }, "mixin-deep": { @@ -5167,10 +5238,16 @@ "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, "requires": { "minimist": "^1.2.5" } }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5194,49 +5271,38 @@ "to-regex": "^3.0.1" } }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, - "needle": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.5.2.tgz", - "integrity": "sha512-LbRIwS9BfkPvNwNHlsA41Q29kL2L/6VaOJ0qisM5lLWsTV3nP15abO5ITL6L81zqFhzjRKDAYjpcBcwM0AVvLQ==", - "requires": { - "debug": "^3.2.6", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "requires": { - "ms": "^2.1.1" - } - } - } - }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, + "node-abi": { + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.26.0.tgz", + "integrity": "sha512-ag/Vos/mXXpWLLAYWsAoQdgS+gW7IwvgMLOgqopm/DbzAjazLltzgzpVMsFlgmo9TzG5hGXeaBZx2AI731RIsQ==", + "requires": { + "semver": "^5.4.1" + } + }, "node-addon-api": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.2.tgz", - "integrity": "sha512-+D4s2HCnxPd5PjjI0STKwncjXTUKKqm74MDMz9OPXavjsGmjkvwgLtA5yoxJUdmpj52+2u+RrXgPipahKczMKg==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", + "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "node-int64": { "version": "0.4.0", @@ -5257,6 +5323,7 @@ "version": "8.0.1", "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz", "integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==", + "optional": true, "requires": { "growly": "^1.3.0", "is-wsl": "^2.2.0", @@ -5270,6 +5337,7 @@ "version": "7.3.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "optional": true, "requires": { "lru-cache": "^6.0.0" } @@ -5278,66 +5346,22 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "optional": true, "requires": { "isexe": "^2.0.0" } } } }, - "node-pre-gyp": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.15.0.tgz", - "integrity": "sha512-7QcZa8/fpaU/BKenjcaeFF9hLz2+7S9AqyXFhlH/rilsQ/hPZKK32RtR5EQHJElgu+q5RfbJ34KriI79UWaorA==", - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.3", - "needle": "^2.5.0", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4.4.2" - }, - "dependencies": { - "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "requires": { - "glob": "^7.1.3" - } - }, - "tar": { - "version": "4.4.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", - "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.8.6", - "minizlib": "^1.2.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.3" - } - } - } - }, "node-releases": { "version": "1.1.61", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.61.tgz", "integrity": "sha512-DD5vebQLg8jLCOzwupn954fbIiZht05DAZs0k2u8NStSe6h9XdsuIQL8hSRKYiU8WUQRznmSDrKGbv3ObOmC7g==" }, - "nopt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", - "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } + "noop-logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", + "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" }, "normalize-package-data": { "version": "2.5.0", @@ -5355,29 +5379,6 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, - "npm-bundled": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.1.tgz", - "integrity": "sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA==", - "requires": { - "npm-normalize-package-bin": "^1.0.1" - } - }, - "npm-normalize-package-bin": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz", - "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==" - }, - "npm-packlist": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz", - "integrity": "sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A==", - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1", - "npm-normalize-package-bin": "^1.0.1" - } - }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -5544,25 +5545,6 @@ "word-wrap": "~1.2.3" } }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, "p-each-series": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-2.1.0.tgz", @@ -5695,6 +5677,28 @@ "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=" }, + "prebuild-install": { + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.6.tgz", + "integrity": "sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==", + "requires": { + "detect-libc": "^1.0.3", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^2.7.0", + "noop-logger": "^0.1.1", + "npmlog": "^4.0.1", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^3.0.3", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0", + "which-pm-runs": "^1.0.0" + } + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -5926,9 +5930,9 @@ } }, "react-clone-referenced-element": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/react-clone-referenced-element/-/react-clone-referenced-element-1.1.0.tgz", - "integrity": "sha512-FKOsfKbBkPxYE8576EM6uAfHC4rnMpLyH6/TJUL4WcHUEB3EUn8AxPjnnV/IiwSSzsClvHYK+sDELKN/EJ0WYg==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/react-clone-referenced-element/-/react-clone-referenced-element-1.1.1.tgz", + "integrity": "sha512-LZBPvQV8W0B5dFzXFu+D3Tpil8YHS8tO00iFsfXcTLdtpuH7XyvaHqHcoz4hd4uNPQCZ30fceh+s7mLznzMXvg==" }, "react-is": { "version": "16.13.1", @@ -5978,21 +5982,22 @@ } }, "realm": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/realm/-/realm-10.0.1.tgz", - "integrity": "sha512-o3dUNZgydUcAIKsXd2QkoRuM1awmx0i56QUy9xbmpOB2CdvgbpX7fPb9cmusjVYml2tNbhu2EGF8jB0Tem8M6A==", + "version": "10.5.0-beta.1", + "resolved": "https://registry.npmjs.org/realm/-/realm-10.5.0-beta.1.tgz", + "integrity": "sha512-7uK4h1mnZ/GCEVWo+b3TumcC76lKvg7O6qEbHtmMsrlVlySDBbDf5riAzYzvwRNCjGn+GnT+lIESODQ1f1ZG9w==", "requires": { - "bson": "^4.0.3", + "bindings": "^1.5.0", + "bson": "^4.3.0", "command-line-args": "^4.0.6", "deepmerge": "2.1.0", "deprecated-react-native-listview": "0.0.6", "fs-extra": "^4.0.3", "https-proxy-agent": "^2.2.4", - "ini": "^1.3.5", - "node-addon-api": "^3.0.0", - "node-fetch": "^1.7.3", + "ini": "^1.3.7", + "node-addon-api": "^3.1.0", + "node-fetch": "^2.6.1", "node-machine-id": "^1.1.10", - "node-pre-gyp": "^0.15.0", + "prebuild-install": "^5.3.5", "progress": "^2.0.3", "prop-types": "^15.6.2", "realm-network-transport": "^0.7.0", @@ -6003,6 +6008,14 @@ "url-parse": "^1.4.4" }, "dependencies": { + "bson": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.3.0.tgz", + "integrity": "sha512-LkKKeFJx5D6RRCRvLE+fDs40M2ZQNuk7W7tFXmKd7OOcQQ+BHdzCgRdL4XEGjc1UEGtiYuMvIVk91Bv8qsI50A==", + "requires": { + "buffer": "^5.6.0" + } + }, "deepmerge": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.1.0.tgz", @@ -6017,13 +6030,6 @@ "requires": { "abort-controller": "^3.0.0", "node-fetch": "^2.6.0" - }, - "dependencies": { - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" - } } }, "regenerate": { @@ -6404,11 +6410,6 @@ } } }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, "saxes": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", @@ -6469,13 +6470,46 @@ "shellwords": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", - "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==" + "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", + "optional": true + }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "dependencies": { + "object-inspect": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", + "integrity": "sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==" + } + } }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", + "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", + "requires": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -6889,6 +6923,62 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, + "superagent": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", + "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", + "requires": { + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.2", + "debug": "^4.1.1", + "fast-safe-stringify": "^2.0.7", + "form-data": "^3.0.0", + "formidable": "^1.2.2", + "methods": "^1.1.2", + "mime": "^2.4.6", + "qs": "^6.9.4", + "readable-stream": "^3.6.0", + "semver": "^7.3.2" + }, + "dependencies": { + "form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "qs": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.1.tgz", + "integrity": "sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==", + "requires": { + "side-channel": "^1.0.4" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -6974,9 +7064,9 @@ } }, "tar": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.5.tgz", - "integrity": "sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz", + "integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==", "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", @@ -6991,40 +7081,45 @@ "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" }, - "fs-minipass": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", - "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", - "requires": { - "minipass": "^3.0.0" - } - }, - "minipass": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", - "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", - "requires": { - "yallist": "^4.0.0" - } - }, - "minizlib": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", - "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", - "requires": { - "minipass": "^3.0.0", - "yallist": "^4.0.0" - } - }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, + "tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } } } }, @@ -7100,7 +7195,11 @@ "tld-list": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/tld-list/-/tld-list-1.0.0.tgz", - "integrity": "sha1-cXPudZKysBs83KF1jVShJymSiis=" + "integrity": "sha1-cXPudZKysBs83KF1jVShJymSiis=", + "requires": { + "punycode": "^2.1.1", + "superagent": "^6.1.0" + } }, "tmpl": { "version": "1.0.4", @@ -7329,9 +7428,9 @@ "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=" }, "ua-parser-js": { - "version": "0.7.22", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.22.tgz", - "integrity": "sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q==" + "version": "0.7.28", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz", + "integrity": "sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==" }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", @@ -7423,9 +7522,9 @@ "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=" }, "url-parse": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", - "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz", + "integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -7444,7 +7543,8 @@ "uuid": { "version": "8.3.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", - "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" + "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==", + "optional": true }, "v8-compile-cache": { "version": "2.1.1", @@ -7553,6 +7653,11 @@ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=" + }, "wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", @@ -7651,9 +7756,9 @@ "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" }, "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yargs": { "version": "15.4.1", diff --git a/examples/node/package.json b/examples/node/package.json index d65139f6e3..b151611cfe 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "jest", - "test:js": "jest --selectProjects JavaScript", + "test:js": "jest --onlyChanged --selectProjects JavaScript", "test:ts": "jest --selectProjects TypeScript", "lint": "eslint Examples/*", "prettier": "prettier --write Examples/*" @@ -25,7 +25,7 @@ "jest": "^26.5.3", "prettier": "^2.1.2", "random-email": "^1.0.3", - "realm": "^10.0.1", + "realm": "^10.5.0-beta.1", "ts-jest": "^26.4.1", "typescript": "^4.0.3" }, diff --git a/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js new file mode 100644 index 0000000000..bf2304528e --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js @@ -0,0 +1,9 @@ +summerHillHouse.addListener((changedHouse, changes) => { + console.log( + `The following changes have occurred in the home: ${JSON.stringify( + changes, + null, + 2 + )}` + ); +}); diff --git a/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js b/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js new file mode 100644 index 0000000000..c11530fa9b --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js @@ -0,0 +1,13 @@ +let sanDiegoCity; +realm.write(() => { + sanDiegoCity = realm.create("City", { + name: "san diego", + home: { + windows: 5, + doors: 3, + floor: 1, + color: "red", + address: "Summerhill St.", + }, + }); +}); diff --git a/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js b/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js new file mode 100644 index 0000000000..229fdf0812 --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js @@ -0,0 +1,7 @@ +const CitySchema = { + name: "City", + properties: { + name: "string", + home: "{}", + }, +}; diff --git a/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js new file mode 100644 index 0000000000..149c36b55b --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js @@ -0,0 +1,15 @@ +// find all houses in san diego +const housesInSanDiego = realm + .objects("City") + .filtered("name = 'san diego'"); +// filtered for a house with the address Summerhill St. +const summerHillHouse = housesInSanDiego.filtered( + `home['address'] = "Summerhill St."` +)[0]; + +// Find all houses that has windows as a key. +const housesWithWindows = housesInSanDiego.filtered( + `home.@keys = "windows" ` +); +// find all houses that has any field with a value of 'red' +const redHouses = housesInSanDiego.filtered(`home.@values = "red" `); diff --git a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js new file mode 100644 index 0000000000..240c5faad3 --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js @@ -0,0 +1,4 @@ +realm.write(() => { + // remove the 'color' and 'floors' field of the Yakima City Victorian Home + yakimaCity.home.remove(["color", "floor"]); +}); diff --git a/source/examples/generated/node/data-types.codeblock.set-additional-fields.js b/source/examples/generated/node/data-types.codeblock.set-additional-fields.js new file mode 100644 index 0000000000..39b45e4df8 --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.set-additional-fields.js @@ -0,0 +1,4 @@ +// use the `put()` method to set a new field, yearBuilt, to the yakimaCity home +yakimaCity.home.put({ yearBuilt: 1993 }); +// alternatively, use dot notation to add a new field, price, to the yakimaCity home +yakimaCity.home.price = 512400; diff --git a/source/examples/generated/node/data-types.codeblock.setting-new-dictionaries-to-existing-objects.js b/source/examples/generated/node/data-types.codeblock.setting-new-dictionaries-to-existing-objects.js new file mode 100644 index 0000000000..b33e02b6cf --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.setting-new-dictionaries-to-existing-objects.js @@ -0,0 +1,14 @@ +let newVictorianHome; +realm.write(() => { + newVictorianHome = { + doors: 4, + floor: 3, + color: "white", + address: "Trailwoods Rd.", + }; + // use the `put()` method to add a dictionary to a pre-existing city in the database + summerHillHouse.home.put(newVictorianHome); + + // alternatively, use dot notation to add a dictionary to a pre-existing city + yakimaCity.home = newVictorianHome; +}); diff --git a/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js new file mode 100644 index 0000000000..0930684104 --- /dev/null +++ b/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js @@ -0,0 +1,7 @@ +// update an existing home, from an existing city in the database +realm.write(() => { + // use the `put()` method to add a field to a dictionary property + summerHillHouse.home.put({ style: "Victorian" }); + // alternatively, set a field of a dictionary through dot notation + summerHillHouse.color = "brown"; +}); diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index 2cb7da0910..d889bb5012 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -23,21 +23,49 @@ keys paired with values. The ``dictionary`` data maps to the Javascript Realm Object Models ------------------- +.. literalinclude:: /examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js + :language: javascript Create a Dictionary ------------------- +.. literalinclude:: /examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js + :language: javascript + + +Query for Objects with a Dictionary Property +-------------------------------------------- +.. literalinclude:: /examples/generated/node/data-types.codeblock.query-a-dictionary.js + :language: javascript + + +Add a Listener to a Dictionary +------------------------------ +.. literalinclude:: /examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js + :language: javascript + Update a Dictionary ------------------- Update an Existing Field of a Dictionary ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Add a New Field to a Dictionary -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. literalinclude:: /examples/generated/node/data-types.codeblock.update-a-dictionary.js + :language: javascript + +Add New Fields to a Dictionary +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. literalinclude:: /examples/generated/node/data-types.codeblock.set-additional-fields.js + :language: javascript + +Overwrite a Dictionary +~~~~~~~~~~~~~~~~~~~~~~ +.. literalinclude:: /examples/generated/node/data-types.codeblock.setting-new-dictionaries-to-existing-objects.js + :language: javascript + Delete Members of a Dictionary ------------------------------ -Query for Objects with a Dictionary Property --------------------------------------------- +.. literalinclude:: /examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js + :language: javascript From 4965ec397c3033316558f3728673c612d1ec0e92 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Mon, 10 May 2021 16:31:39 -0400 Subject: [PATCH 03/12] Update examples/node/package.json --- examples/node/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/node/package.json b/examples/node/package.json index b151611cfe..a338c12a4d 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "jest", - "test:js": "jest --onlyChanged --selectProjects JavaScript", + "test:js": "jest --selectProjects JavaScript", "test:ts": "jest --selectProjects TypeScript", "lint": "eslint Examples/*", "prettier": "prettier --write Examples/*" From a51bb7cb2e410bc75063bf174d3c96d04a41240d Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Mon, 10 May 2021 23:47:51 -0400 Subject: [PATCH 04/12] removed unneeded file --- .../node/data-types.codeblock.set-additional-fields.js | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 source/examples/generated/node/data-types.codeblock.set-additional-fields.js diff --git a/source/examples/generated/node/data-types.codeblock.set-additional-fields.js b/source/examples/generated/node/data-types.codeblock.set-additional-fields.js deleted file mode 100644 index 39b45e4df8..0000000000 --- a/source/examples/generated/node/data-types.codeblock.set-additional-fields.js +++ /dev/null @@ -1,4 +0,0 @@ -// use the `put()` method to set a new field, yearBuilt, to the yakimaCity home -yakimaCity.home.put({ yearBuilt: 1993 }); -// alternatively, use dot notation to add a new field, price, to the yakimaCity home -yakimaCity.home.price = 512400; From 0b76e7780fdfe6008c7f447f21b72fe8c3398620 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Mon, 10 May 2021 23:49:26 -0400 Subject: [PATCH 05/12] Added new examples for dictionaries --- examples/node/Examples/data-types.js | 118 +++++++----------- ...odeblock.add-a-listener-to-a-dictionary.js | 8 +- ...eblock.create-realm-obj-with-dictionary.js | 16 ++- ...s.codeblock.define-dictionary-in-schema.js | 4 +- ...data-types.codeblock.query-a-dictionary.js | 23 ++-- ...deblock.remove-fields-of-the-dictionary.js | 4 +- ...ata-types.codeblock.update-a-dictionary.js | 9 +- source/sdk/node/data-types/dictionaries.txt | 24 ++-- 8 files changed, 85 insertions(+), 121 deletions(-) diff --git a/examples/node/Examples/data-types.js b/examples/node/Examples/data-types.js index fa57abceb9..8ea27ae59b 100644 --- a/examples/node/Examples/data-types.js +++ b/examples/node/Examples/data-types.js @@ -3,8 +3,8 @@ import Realm from "realm"; describe("Node.js Data Types", () => { test("should create, update and query Realm dictionaries", async () => { // :code-block-start: define-dictionary-in-schema - const CitySchema = { - name: "City", + const PersonSchema = { + name: "Person", properties: { name: "string", home: "{}", @@ -13,45 +13,54 @@ describe("Node.js Data Types", () => { // :code-block-end: const realm = await Realm.open({ - schema: [CitySchema], + schema: [PersonSchema], }); // :code-block-start: create-realm-obj-with-dictionary - let sanDiegoCity; + let johnDoe; + let janeSmith; realm.write(() => { - sanDiegoCity = realm.create("City", { - name: "san diego", + johnDoe = realm.create("Person", { + name: "John Doe", home: { windows: 5, doors: 3, - floor: 1, color: "red", address: "Summerhill St.", + price: 400123, + }, + }); + janeSmith = realm.create("Person", { + name: "Jane Smith", + home: { + address: "100 northroad st.", + yearBuilt: 1990, }, }); }); // :code-block-end: // :code-block-start: query-a-dictionary - // find all houses in san diego - const housesInSanDiego = realm - .objects("City") - .filtered("name = 'san diego'"); - // filtered for a house with the address Summerhill St. - const summerHillHouse = housesInSanDiego.filtered( + // query for all Person objects + const persons = realm.objects("Person"); + + // run the `.filtered()` method on all the returned persons to find the house with the address "Summerhill St." + const summerHillHouse = persons.filtered( `home['address'] = "Summerhill St."` - )[0]; + )[0].home; - // Find all houses that has windows as a key. - const housesWithWindows = housesInSanDiego.filtered( - `home.@keys = "windows" ` + // Find all people that have a house with a listed price + const peopleWithHousesWithAListedPrice = persons.filtered( + `home.@keys = "price" ` ); - // find all houses that has any field with a value of 'red' - const redHouses = housesInSanDiego.filtered(`home.@values = "red" `); + // find a house that has any field with a value of 'red' + const redHouse = persons.filtered(`home.@values = "red" `)[0].home; // :code-block-end: // the following assertion tests both creation of a dictionary + querying a dictionary - expect(housesInSanDiego[0].home.windows).toBe(5); // there should be 5 windows in the houses in san diego + expect(summerHillHouse.windows).toBe(5); // there should be 5 windows in the summer hill house + expect(peopleWithHousesWithAListedPrice.length).toBe(1); // there should only be one house with a listed price + expect(redHouse.doors).toBe(3); // the red house should have 3 doors let dictionaryListenerHasBeenCalled = false; // :code-block-start: add-a-listener-to-a-dictionary @@ -59,79 +68,40 @@ describe("Node.js Data Types", () => { // :hide-start: dictionaryListenerHasBeenCalled = true; // :hide-end: - console.log( - `The following changes have occurred in the home: ${JSON.stringify( - changes, - null, - 2 - )}` - ); + console.log("A change has occurred to the Summer Hill House Object"); }); // :code-block-end: // :code-block-start: update-a-dictionary - // update an existing home, from an existing city in the database realm.write(() => { - // use the `put()` method to add a field to a dictionary property - summerHillHouse.home.put({ style: "Victorian" }); - // alternatively, set a field of a dictionary through dot notation + // use the `put()` method to update a field of a dictionary + summerHillHouse.price = 400100; + // alternatively, update a field of a dictionary through dot notation summerHillHouse.color = "brown"; + // update a dictionary by adding a field + summerHillHouse.yearBuilt = 2004; }); // :code-block-end: expect(dictionaryListenerHasBeenCalled).toBe(true); // a home (dictionary inside a realm object) should be able to have a change listener - expect(summerHillHouse.home.style).toBe("Victorian"); // the summerHillHouse should be a Victorian style house - - let queensCity, yakimaCity; - realm.write(() => { - queensCity = realm.create("City", { - name: "Richmond Hill, Queens, NY", - }); - yakimaCity = realm.create("City", { - name: "Yakima, Washington", - }); - }); - - // :code-block-start: setting-new-dictionaries-to-existing-objects - let newVictorianHome; - realm.write(() => { - newVictorianHome = { - doors: 4, - floor: 3, - color: "white", - address: "Trailwoods Rd.", - }; - // use the `put()` method to add a dictionary to a pre-existing city in the database - summerHillHouse.home.put(newVictorianHome); - - // alternatively, use dot notation to add a dictionary to a pre-existing city - yakimaCity.home = newVictorianHome; - }); - // :code-block-end: - - // :code-block-start: set-additional-fields - // use the `put()` method to set a new field, yearBuilt, to the yakimaCity home - yakimaCity.home.put({ yearBuilt: 1993 }); - // alternatively, use dot notation to add a new field, price, to the yakimaCity home - yakimaCity.home.price = 512400; - // :code-block-end: - - expect(yakimaCity.home.color).toBe("white"); // yakimaCity's home should be updated with the newVictorianHome 'white' color + expect(summerHillHouse.price).toBe(400100); // the summerHillHouse should be $400,100 now + expect(summerHillHouse.color).toBe("brown"); // the summerHillHouse should be brown now + expect(summerHillHouse.yearBuilt).toBe(2004); // the summerHillHouse should've been built in 2004 // :code-block-start: remove-fields-of-the-dictionary realm.write(() => { - // remove the 'color' and 'floors' field of the Yakima City Victorian Home - yakimaCity.home.remove(["color", "floor"]); + // remove the 'color' and 'floors' field of the Summerhill House. + summerHillHouse.remove(["windows", "doors"]); }); // :code-block-end: - expect(yakimaCity.home.color).toBe(undefined); // since color has been removed as a field, it should be undefined + expect(summerHillHouse.color).toBe(undefined); // since color has been removed as a field, it should be undefined + expect(summerHillHouse.floor).toBe(undefined); // since color has been removed as a field, it should be undefined // delete the objects to keep the test idempotent realm.write(() => { - realm.delete(sanDiegoCity); - realm.delete(queensCity); - realm.delete(yakimaCity); + realm.delete(johnDoe); + realm.delete(janeSmith); }); // close the realm to avoid memory leaks realm.close(); diff --git a/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js index bf2304528e..0baa1bb755 100644 --- a/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js @@ -1,9 +1,3 @@ summerHillHouse.addListener((changedHouse, changes) => { - console.log( - `The following changes have occurred in the home: ${JSON.stringify( - changes, - null, - 2 - )}` - ); + console.log("A change has occurred to the Summer Hill House Object"); }); diff --git a/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js b/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js index c11530fa9b..f2d78b2f33 100644 --- a/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js @@ -1,13 +1,21 @@ -let sanDiegoCity; +let johnDoe; +let janeSmith; realm.write(() => { - sanDiegoCity = realm.create("City", { - name: "san diego", + johnDoe = realm.create("Person", { + name: "John Doe", home: { windows: 5, doors: 3, - floor: 1, color: "red", address: "Summerhill St.", + price: 400123, + }, + }); + janeSmith = realm.create("Person", { + name: "Jane Smith", + home: { + address: "100 northroad st.", + yearBuilt: 1990, }, }); }); diff --git a/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js b/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js index 229fdf0812..da81df7a04 100644 --- a/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js +++ b/source/examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js @@ -1,5 +1,5 @@ -const CitySchema = { - name: "City", +const PersonSchema = { + name: "Person", properties: { name: "string", home: "{}", diff --git a/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js index 149c36b55b..bbd91ad4b9 100644 --- a/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.query-a-dictionary.js @@ -1,15 +1,14 @@ -// find all houses in san diego -const housesInSanDiego = realm - .objects("City") - .filtered("name = 'san diego'"); -// filtered for a house with the address Summerhill St. -const summerHillHouse = housesInSanDiego.filtered( +// query for all Person objects +const persons = realm.objects("Person"); + +// run the `.filtered()` method on all the returned persons to find the house with the address "Summerhill St." +const summerHillHouse = persons.filtered( `home['address'] = "Summerhill St."` -)[0]; +)[0].home; -// Find all houses that has windows as a key. -const housesWithWindows = housesInSanDiego.filtered( - `home.@keys = "windows" ` +// Find all people that have a house with a listed price +const peopleWithHousesWithAListedPrice = persons.filtered( + `home.@keys = "price" ` ); -// find all houses that has any field with a value of 'red' -const redHouses = housesInSanDiego.filtered(`home.@values = "red" `); +// find a house that has any field with a value of 'red' +const redHouse = persons.filtered(`home.@values = "red" `)[0].home; diff --git a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js index 240c5faad3..1fb787d757 100644 --- a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js @@ -1,4 +1,4 @@ realm.write(() => { - // remove the 'color' and 'floors' field of the Yakima City Victorian Home - yakimaCity.home.remove(["color", "floor"]); + // remove the 'color' and 'floors' field of the Summerhill House. + summerHillHouse.remove(["windows", "doors"]); }); diff --git a/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js index 0930684104..f632ed7d76 100644 --- a/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js @@ -1,7 +1,8 @@ -// update an existing home, from an existing city in the database realm.write(() => { - // use the `put()` method to add a field to a dictionary property - summerHillHouse.home.put({ style: "Victorian" }); - // alternatively, set a field of a dictionary through dot notation + // use the `put()` method to update a field of a dictionary + summerHillHouse.price = 400100; + // alternatively, update a field of a dictionary through dot notation summerHillHouse.color = "brown"; + // update a dictionary by adding a field + summerHillHouse.yearBuilt = 2004; }); diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index d889bb5012..4406d6bc45 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -18,21 +18,24 @@ Overview -------- You can use the ``dictionary`` data type to manage a collection of unique String keys paired with values. The ``dictionary`` data maps to the Javascript -:mdn:`Object ` type. +:mdn:`Object ` type. Realm Object Models ------------------- +To define a dictionary in your object model, set the data type of your field to an empty object, ``"{}"``. + .. literalinclude:: /examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js :language: javascript -Create a Dictionary -------------------- +Create an Object with a Dictionary Value +----------------------------------------- +Create an object with a dictionary value by running the :js-sdk:`realm.create() +` method within a write transaction. .. literalinclude:: /examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js :language: javascript - Query for Objects with a Dictionary Property -------------------------------------------- .. literalinclude:: /examples/generated/node/data-types.codeblock.query-a-dictionary.js @@ -46,19 +49,8 @@ Add a Listener to a Dictionary Update a Dictionary ------------------- -Update an Existing Field of a Dictionary -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. literalinclude:: /examples/generated/node/data-types.codeblock.update-a-dictionary.js - :language: javascript - -Add New Fields to a Dictionary -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. literalinclude:: /examples/generated/node/data-types.codeblock.set-additional-fields.js - :language: javascript -Overwrite a Dictionary -~~~~~~~~~~~~~~~~~~~~~~ -.. literalinclude:: /examples/generated/node/data-types.codeblock.setting-new-dictionaries-to-existing-objects.js +.. literalinclude:: /examples/generated/node/data-types.codeblock.update-a-dictionary.js :language: javascript From d19ac0e09bcbc9494ac2da57b13a69d6cc49b0b1 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Tue, 11 May 2021 09:00:08 -0400 Subject: [PATCH 06/12] update dictionary examples --- examples/node/Examples/data-types.js | 13 +++---- ...deblock.remove-fields-of-the-dictionary.js | 2 +- ...ata-types.codeblock.update-a-dictionary.js | 2 +- source/sdk/node/data-types/dictionaries.txt | 35 +++++++++++++++---- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/examples/node/Examples/data-types.js b/examples/node/Examples/data-types.js index 8ea27ae59b..0d08f2bfcf 100644 --- a/examples/node/Examples/data-types.js +++ b/examples/node/Examples/data-types.js @@ -58,7 +58,6 @@ describe("Node.js Data Types", () => { // :code-block-end: // the following assertion tests both creation of a dictionary + querying a dictionary - expect(summerHillHouse.windows).toBe(5); // there should be 5 windows in the summer hill house expect(peopleWithHousesWithAListedPrice.length).toBe(1); // there should only be one house with a listed price expect(redHouse.doors).toBe(3); // the red house should have 3 doors @@ -75,7 +74,7 @@ describe("Node.js Data Types", () => { // :code-block-start: update-a-dictionary realm.write(() => { // use the `put()` method to update a field of a dictionary - summerHillHouse.price = 400100; + summerHillHouse.put({ price: 400100 }); // alternatively, update a field of a dictionary through dot notation summerHillHouse.color = "brown"; // update a dictionary by adding a field @@ -90,13 +89,15 @@ describe("Node.js Data Types", () => { // :code-block-start: remove-fields-of-the-dictionary realm.write(() => { - // remove the 'color' and 'floors' field of the Summerhill House. - summerHillHouse.remove(["windows", "doors"]); + // remove the 'color' and 'doors' field of the Summerhill House. + // :uncomment-start: + // summerHillHouse.remove(["windows", "doors"]); + // :uncomment-end: }); // :code-block-end: - expect(summerHillHouse.color).toBe(undefined); // since color has been removed as a field, it should be undefined - expect(summerHillHouse.floor).toBe(undefined); // since color has been removed as a field, it should be undefined + // expect(summerHillHouse.windows).toBe(undefined); // since windows has been removed as a field, it should be undefined + // expect(summerHillHouse.doors).toBe(undefined); // since doors has been removed as a field, it should be undefined // delete the objects to keep the test idempotent realm.write(() => { diff --git a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js index 1fb787d757..69d33028a0 100644 --- a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js @@ -1,4 +1,4 @@ realm.write(() => { - // remove the 'color' and 'floors' field of the Summerhill House. + // remove the 'color' and 'doors' field of the Summerhill House. summerHillHouse.remove(["windows", "doors"]); }); diff --git a/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js index f632ed7d76..e042ed69dc 100644 --- a/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.update-a-dictionary.js @@ -1,6 +1,6 @@ realm.write(() => { // use the `put()` method to update a field of a dictionary - summerHillHouse.price = 400100; + summerHillHouse.put({ price: 400100 }); // alternatively, update a field of a dictionary through dot notation summerHillHouse.color = "brown"; // update a dictionary by adding a field diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index 4406d6bc45..c05833bd1c 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -28,34 +28,55 @@ To define a dictionary in your object model, set the data type of your field to .. literalinclude:: /examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js :language: javascript +Add a Listener to a Dictionary +------------------------------ +You can add a listener to a dictionary by running the +:js-sdk:`dictionary.addListener() ` method. The +``addListener`` method's callback function has two parameters, the changed +dictionary and an array of changes describing how the dictionary was changed. + +.. note:: + + Learn more about :ref:`change notifications `. + +.. literalinclude:: /examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js + :language: javascript + + Create an Object with a Dictionary Value ----------------------------------------- Create an object with a dictionary value by running the :js-sdk:`realm.create() -` method within a write transaction. +` method within a write transaction. .. literalinclude:: /examples/generated/node/data-types.codeblock.create-realm-obj-with-dictionary.js :language: javascript Query for Objects with a Dictionary Property -------------------------------------------- -.. literalinclude:: /examples/generated/node/data-types.codeblock.query-a-dictionary.js - :language: javascript +To filter a query, run :js-sdk:`collection.filtered() +` to specify a subset of results based on the +value(s) of one or more object properties. You can specify results based on the value of a +dictionary's properties by using :mdn:`bracket-notation `. +You can also determine whether a results collection has a certain key or value +by using ``.@keys`` or ``.@values``. For instance, if +you had a ``Person`` collection with a nested ``home`` dictionary, you could +determine return all ``Person`` objects with a ``home`` with a ``"price"`` +property by running the query: ``home.@keys = "price"``. -Add a Listener to a Dictionary ------------------------------- -.. literalinclude:: /examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js +.. literalinclude:: /examples/generated/node/data-types.codeblock.query-a-dictionary.js :language: javascript Update a Dictionary ------------------- +To update a dictionary's properties, use dot notation or the ``dictionary.put()`` method. .. literalinclude:: /examples/generated/node/data-types.codeblock.update-a-dictionary.js :language: javascript - Delete Members of a Dictionary ------------------------------ +To delete members of a dictionary, use the ``dictionary.remove()`` method with an array of properties to remove from the dictionary. .. literalinclude:: /examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js :language: javascript From b1b4b997f3a1d2666347c323bcd80cab71f0785e Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Tue, 11 May 2021 09:05:45 -0400 Subject: [PATCH 07/12] fix capitalization --- examples/node/Examples/data-types.js | 2 +- .../node/data-types.codeblock.add-a-listener-to-a-dictionary.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/node/Examples/data-types.js b/examples/node/Examples/data-types.js index 0d08f2bfcf..60fd2a9d10 100644 --- a/examples/node/Examples/data-types.js +++ b/examples/node/Examples/data-types.js @@ -67,7 +67,7 @@ describe("Node.js Data Types", () => { // :hide-start: dictionaryListenerHasBeenCalled = true; // :hide-end: - console.log("A change has occurred to the Summer Hill House Object"); + console.log("A change has occurred to the Summer Hill House object"); }); // :code-block-end: diff --git a/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js b/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js index 0baa1bb755..ae502f1252 100644 --- a/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js @@ -1,3 +1,3 @@ summerHillHouse.addListener((changedHouse, changes) => { - console.log("A change has occurred to the Summer Hill House Object"); + console.log("A change has occurred to the Summer Hill House object"); }); From 4bb6247ce2b4a2d6ef2632a9012e43ff2659b23f Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Tue, 11 May 2021 10:19:03 -0400 Subject: [PATCH 08/12] moved addlistener down --- source/sdk/node/data-types/dictionaries.txt | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index c05833bd1c..7aa40fb0d5 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -28,21 +28,6 @@ To define a dictionary in your object model, set the data type of your field to .. literalinclude:: /examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js :language: javascript -Add a Listener to a Dictionary ------------------------------- -You can add a listener to a dictionary by running the -:js-sdk:`dictionary.addListener() ` method. The -``addListener`` method's callback function has two parameters, the changed -dictionary and an array of changes describing how the dictionary was changed. - -.. note:: - - Learn more about :ref:`change notifications `. - -.. literalinclude:: /examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js - :language: javascript - - Create an Object with a Dictionary Value ----------------------------------------- Create an object with a dictionary value by running the :js-sdk:`realm.create() @@ -67,6 +52,20 @@ property by running the query: ``home.@keys = "price"``. .. literalinclude:: /examples/generated/node/data-types.codeblock.query-a-dictionary.js :language: javascript +Add a Listener to a Dictionary +------------------------------ +You can add a listener to a dictionary by running the +:js-sdk:`dictionary.addListener() ` method. The +``addListener`` method's callback function has two parameters, the changed +dictionary and an array of changes describing how the dictionary was changed. + +.. note:: + + Learn more about :ref:`change notifications `. + +.. literalinclude:: /examples/generated/node/data-types.codeblock.add-a-listener-to-a-dictionary.js + :language: javascript + Update a Dictionary ------------------- To update a dictionary's properties, use dot notation or the ``dictionary.put()`` method. From 4406d439b5891ade12c0ae8473a3de0f6a3db8f5 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Thu, 13 May 2021 01:00:56 -0400 Subject: [PATCH 09/12] fix comment --- examples/node/Examples/data-types.js | 3 ++- .../data-types.codeblock.remove-fields-of-the-dictionary.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/node/Examples/data-types.js b/examples/node/Examples/data-types.js index 60fd2a9d10..0533efcda6 100644 --- a/examples/node/Examples/data-types.js +++ b/examples/node/Examples/data-types.js @@ -87,9 +87,10 @@ describe("Node.js Data Types", () => { expect(summerHillHouse.color).toBe("brown"); // the summerHillHouse should be brown now expect(summerHillHouse.yearBuilt).toBe(2004); // the summerHillHouse should've been built in 2004 + console.log(summerHillHouse); // :code-block-start: remove-fields-of-the-dictionary realm.write(() => { - // remove the 'color' and 'doors' field of the Summerhill House. + // remove the 'windows' and 'doors' field of the Summerhill House. // :uncomment-start: // summerHillHouse.remove(["windows", "doors"]); // :uncomment-end: diff --git a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js index 69d33028a0..3f51202fe2 100644 --- a/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js +++ b/source/examples/generated/node/data-types.codeblock.remove-fields-of-the-dictionary.js @@ -1,4 +1,4 @@ realm.write(() => { - // remove the 'color' and 'doors' field of the Summerhill House. + // remove the 'windows' and 'doors' field of the Summerhill House. summerHillHouse.remove(["windows", "doors"]); }); From 069be991f0b2c7144ffa3935cf7042e2fdc858ee Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Thu, 13 May 2021 01:05:25 -0400 Subject: [PATCH 10/12] update wording to be clearer on type usage in dict --- source/sdk/node/data-types/dictionaries.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index 7aa40fb0d5..d4641740b0 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -23,7 +23,9 @@ keys paired with values. The ``dictionary`` data maps to the Javascript Realm Object Models ------------------- -To define a dictionary in your object model, set the data type of your field to an empty object, ``"{}"``. +To create a dictionary with values of a specific type, add the data type before +the brackets. For instance, ``"int{}"`` to specify that dictionary values must +be integers or ``"string{}"`` to specify that dictionary values must be strings. .. literalinclude:: /examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js :language: javascript From 978041c8c8ec9c7419f4fe466c5680ca40eef993 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Thu, 13 May 2021 01:22:08 -0400 Subject: [PATCH 11/12] fix wording --- source/sdk/node/data-types/dictionaries.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index d4641740b0..8e6ea9e8c3 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -23,9 +23,11 @@ keys paired with values. The ``dictionary`` data maps to the Javascript Realm Object Models ------------------- -To create a dictionary with values of a specific type, add the data type before -the brackets. For instance, ``"int{}"`` to specify that dictionary values must -be integers or ``"string{}"`` to specify that dictionary values must be strings. +To define a dictionary of mixed values in your object model, set the data type +of your field to an empty object, ``"{}"``. Alternatively, to create a +dictionary with values of a specific type, add the data type before the +brackets. For instance, ``"int{}"`` to specify that dictionary values must be +integers or ``"string{}"`` to specify that dictionary values must be strings. .. literalinclude:: /examples/generated/node/data-types.codeblock.define-dictionary-in-schema.js :language: javascript From 8f544d4c56539b560b19d0d673f461da227702f7 Mon Sep 17 00:00:00 2001 From: Mohammad Hunan Chughtai Date: Thu, 13 May 2021 01:29:04 -0400 Subject: [PATCH 12/12] fix wording --- source/sdk/node/data-types/dictionaries.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sdk/node/data-types/dictionaries.txt b/source/sdk/node/data-types/dictionaries.txt index 8e6ea9e8c3..d53619cd8b 100644 --- a/source/sdk/node/data-types/dictionaries.txt +++ b/source/sdk/node/data-types/dictionaries.txt @@ -23,7 +23,7 @@ keys paired with values. The ``dictionary`` data maps to the Javascript Realm Object Models ------------------- -To define a dictionary of mixed values in your object model, set the data type +To define a dictionary of mixed values in your schema, set the data type of your field to an empty object, ``"{}"``. Alternatively, to create a dictionary with values of a specific type, add the data type before the brackets. For instance, ``"int{}"`` to specify that dictionary values must be