LWW is the simplest & most popular distributed data type, but it isn’t the most intelligent. An LWW is a key-value object, with Unicode-encoded strings as keys, and any arbitrary atoms as values. Values may also be atom tuples. The write with a later timestamp “wins”, overriding any other operations that have happened to the same key before. Nested objects are implemented as UUID references.
1 @~ 'an object is created'; 2 @123+origin :lww ! 3 4 @~ 'set field `age` to value 18, set some other fields too:'; 5 @1234+origin :123+origin 'age' 18; 6 'order' 'beer' 0.5; 7 @~ 'see the chapter on chains on why the second record is missing id/ref'; 8 9 @~ 'empty a field'; 10 @12345+origin :1234000001+origin 'order' ; 11 12 @~ 'the resulting state (no gc)' 13 @123+origin :lww ! 14 @1234+origin 'age' 18, 15 'order' 'beer' 0.5, 16 @12345+origin 'order', 17 18 @~ 'the resulting state (after gc)' 19 @123+origin :lww ! 20 @1234+origin 'age' 18, 21 @12345+origin :1234000001+origin 'order', 22 23 @~ 'undo the emptying (caveats apply - needs a no-gc version!)'; 24 @123456+origin :12345-origin ;