my blog https://overreacted.io

fiex lexicon example

+6 -25
+6 -25
public/a-social-filesystem/index.md
··· 501 501 }; 502 502 ``` 503 503 504 - In TypeScript, we expressed this as a reference to the `Post` type. Since lexicons are JSON files with globally unique names, here's how we'll say this in lexicon: 504 + So, a Like is a record that refers to its Post. 505 505 506 - ```js {12} 507 - { 508 - "lexicon": 1, 509 - "id": "com.twitter.like", 510 - "defs": { 511 - "main": { 512 - "type": "record", 513 - "key": "tid", 514 - "record": { 515 - "type": "object", 516 - "required": ["subject"], 517 - "properties": { 518 - "subject": { "type": "ref", "ref": "com.twitter.post" } 519 - } 520 - } 521 - } 522 - } 523 - } 524 - ``` 506 + But how do we express this in JSON? 525 507 526 - We're saying: a Like is an object with a `subject` field that refers to some Post. 527 - 528 - However, "refers" is doing a lot of work here. What does a Like record actually look like? How do you *actually* refer from inside of one JSON file to another JSON file? 529 508 530 509 ```js 531 510 { 532 511 subject: "???" 533 512 } 534 513 ``` 514 + 515 + How do we refer from one JSON file to another JSON file? 535 516 536 517 We could try to refer to the Post record by its path in our "everything folder": 537 518 ··· 789 770 // ... 790 771 "text": { "type": "string", "maxGraphemes": 300 }, 791 772 "createdAt": { "type": "string", "format": "datetime" }, 792 - "parent": { "type": "ref", "ref": "com.twitter.post" } 773 + "parent": { "type": "string", "format": "at-uri" } 793 774 // ... 794 775 ``` 795 776 796 - This says: the `parent` field is a reference to another `com.twitter.post` record. 777 + This says: the `parent` field is an `at://` link to another record. 797 778 798 779 Every reply to dril's post will have dril's post as their `parent`: 799 780