Declaring annotations

Use annotations to add descriptions to types and links:

  1. type Label {
  2. annotation description :=
  3. 'Special label to stick on reviews';
  4. required property comments -> str;
  5. link review -> Review {
  6. annotation description :=
  7. 'This review needs some attention';
  8. };
  9. }

Retrieving the annotations can be done via an introspection query:

  1. db>
  2. ...
  3. ...
  4. ...
  5. ...
  6. ...
  7. ...
  1. with module schema
  2. select ObjectType {
  3. name,
  4. annotations: {name, @value},
  5. links: {name, annotations: {name, @value}}
  6. }
  7. filter .name = 'default::Label';
  1. {
  2. Object {
  3. name: 'default::Label',
  4. annotations: {
  5. Object {
  6. name: 'std::description',
  7. @value: 'Special label to stick on reviews'
  8. }
  9. },
  10. links: {
  11. Object {
  12. name: 'review',
  13. annotations: {
  14. Object {
  15. name: 'std::description',
  16. @value: 'Special label to stick on reviews'
  17. }
  18. }
  19. },
  20. Object { name: '__type__', annotations: {} }
  21. }
  22. }
  23. }

Alternatively, the annotations can be viewed by the following REPL command:

  1. db>
  1. \d+ Label
  1. type default::Label {
  2. annotation std::description := 'Special label to stick on reviews';
  3. required single link __type__ -> schema::Type {
  4. readonly := true;
  5. };
  6. single link review -> default::Review {
  7. annotation std::description := 'Special label to stick on reviews';
  8. };
  9. required single property comments -> std::str;
  10. required single property id -> std::uuid {
  11. readonly := true;
  12. constraint std::exclusive;
  13. };
  14. };

See also

Schema > Annotations

SDL > Annotations

DDL > Annotations

Introspection > Object types