Object types

This section describes introspection of object types.

Introspection of the schema::ObjectType:

  1. db>
  2. ...
  3. ...
  4. ...
  5. ...
  6. ...
  7. ...
  8. ...
  9. ...
  10. ...
  11. ...
  1. with module schema
  2. select ObjectType {
  3. name,
  4. links: {
  5. name,
  6. },
  7. properties: {
  8. name,
  9. }
  10. }
  11. filter .name = 'schema::ObjectType';
  1. {
  2. Object {
  3. name: 'schema::ObjectType',
  4. links: {
  5. Object { name: '__type__' },
  6. Object { name: 'annotations' },
  7. Object { name: 'bases' },
  8. Object { name: 'constraints' },
  9. Object { name: 'indexes' },
  10. Object { name: 'links' },
  11. Object { name: 'ancestors' },
  12. Object { name: 'pointers' },
  13. Object { name: 'properties' }
  14. },
  15. properties: {
  16. Object { name: 'id' },
  17. Object { name: 'abstract' },
  18. Object { name: 'name' }
  19. }
  20. }
  21. }

Consider the following schema:

  1. type Addressable {
  2. property address -> str;
  3. }
  4. type User extending Addressable {
  5. # define some properties and a link
  6. required property name -> str;
  7. multi link friends -> User;
  8. # define an index for User based on name
  9. index on (.name);
  10. }

Introspection of User:

  1. db>
  2. ...
  3. ...
  4. ...
  5. ...
  6. ...
  7. ...
  8. ...
  9. ...
  10. ...
  11. ...
  12. ...
  13. ...
  14. ...
  15. ...
  16. ...
  17. ...
  18. ...
  19. ...
  20. ...
  21. ...
  22. ...
  23. ...
  1. with module schema
  2. select ObjectType {
  3. name,
  4. abstract,
  5. bases: { name },
  6. ancestors: { name },
  7. annotations: { name, @value },
  8. links: {
  9. name,
  10. cardinality,
  11. required,
  12. target: { name },
  13. },
  14. properties: {
  15. name,
  16. cardinality,
  17. required,
  18. target: { name },
  19. },
  20. constraints: { name },
  21. indexes: { expr },
  22. }
  23. filter .name = 'default::User';
  1. {
  2. Object {
  3. name: 'default::User',
  4. abstract: false,
  5. bases: {Object { name: 'default::Addressable' }},
  6. ancestors: {
  7. Object { name: 'std::BaseObject' },
  8. Object { name: 'std::Object' },
  9. Object { name: 'default::Addressable' }
  10. },
  11. annotations: {},
  12. links: {
  13. Object {
  14. name: '__type__',
  15. cardinality: 'One',
  16. required: {},
  17. target: Object { name: 'schema::Type' }
  18. },
  19. Object {
  20. name: 'friends',
  21. cardinality: 'Many',
  22. required: false,
  23. target: Object { name: 'default::User' }
  24. }
  25. },
  26. properties: {
  27. Object {
  28. name: 'address',
  29. cardinality: 'One',
  30. required: false,
  31. target: Object { name: 'std::str' }
  32. },
  33. Object {
  34. name: 'id',
  35. cardinality: 'One',
  36. required: true,
  37. target: Object { name: 'std::uuid' }
  38. },
  39. Object {
  40. name: 'name',
  41. cardinality: 'One',
  42. required: true,
  43. target: Object { name: 'std::str' }
  44. }
  45. },
  46. constraints: {},
  47. indexes: {
  48. Object {
  49. expr: '.name'
  50. }
  51. }
  52. }
  53. }

See also

Schema > Object types

SDL > Object types

DDL > Object types

Cheatsheets > Object types