diff --git a/docs/documents/values.md b/docs/documents/values.md index b355f8d0..f5abc968 100644 --- a/docs/documents/values.md +++ b/docs/documents/values.md @@ -4,7 +4,10 @@ sidebar_position: 2 # Simple Values -All JSON primitive datatypes are supported in an Automerge document. In addition, JavaScript [Date objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) are supported. +All JSON primitive datatypes (`object`, `array`, `string`, `number`, `boolean`, `null`) are +supported in an Automerge document. In addition, JavaScript [Date +objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) are +supported. _Remember, never modify `currentDoc` directly, only ever change `doc` inside the callback to `Automerge.change`!_ @@ -27,6 +30,21 @@ newDoc = Automerge.change(currentDoc, (doc) => { // cases where you want a string which is not collaborative - URLs for example // should generally be updated in one go. In this case you can use `RawString`, // which does not allow concurrent updates. - doc.atomicStringValue = new Automerge.RawString("") + doc.atomicStringValue = new Automerge.RawString(""); }); ``` + +:::caution +Note that `undefined` is not a valid JSON value, and it can't be used in an Automerge document. +::: + +This will throw an error: + +```js +newdoc = Automerge.change(currentDoc, (doc) => { + doc.something = undefined; // ❌ Cannot assign undefined value at /something +}); +``` + +Instead, you might consider setting a property's value to `null`, or using `delete` to remove it +altogether. diff --git a/package.json b/package.json index c3508025..cb89bb94 100644 --- a/package.json +++ b/package.json @@ -53,5 +53,8 @@ "typedoc": "^0.25.13", "typedoc-plugin-markdown": "^3.17.1", "typescript": "^5.4.5" + }, + "prettier": { + "singleQuote": false } }