my blog https://overreacted.io

fiex lexicon example

+6 -25
+6 -25
public/a-social-filesystem/index.md
··· 501 }; 502 ``` 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: 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 - ``` 525 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 530 ```js 531 { 532 subject: "???" 533 } 534 ``` 535 536 We could try to refer to the Post record by its path in our "everything folder": 537 ··· 789 // ... 790 "text": { "type": "string", "maxGraphemes": 300 }, 791 "createdAt": { "type": "string", "format": "datetime" }, 792 - "parent": { "type": "ref", "ref": "com.twitter.post" } 793 // ... 794 ``` 795 796 - This says: the `parent` field is a reference to another `com.twitter.post` record. 797 798 Every reply to dril's post will have dril's post as their `parent`: 799
··· 501 }; 502 ``` 503 504 + So, a Like is a record that refers to its Post. 505 506 + But how do we express this in JSON? 507 508 509 ```js 510 { 511 subject: "???" 512 } 513 ``` 514 + 515 + How do we refer from one JSON file to another JSON file? 516 517 We could try to refer to the Post record by its path in our "everything folder": 518 ··· 770 // ... 771 "text": { "type": "string", "maxGraphemes": 300 }, 772 "createdAt": { "type": "string", "format": "datetime" }, 773 + "parent": { "type": "string", "format": "at-uri" } 774 // ... 775 ``` 776 777 + This says: the `parent` field is an `at://` link to another record. 778 779 Every reply to dril's post will have dril's post as their `parent`: 780