querying typedb schema
You're probably looking for the statements docs! It has
match
examples on the individual pages. For example,
match user sub $t;
will return all the transitive supertypes of user
(including supertypes of its supertype)
match user sub! $t;
will return only defined supertypes of user
You can also try match $t sub user;
for the reversed purpose!16 Replies
Oh awesome! Managed to get
I think it'd be super useful to add a dedicated section to the schema docs to tell users how to dump the current schema of the database (with some modifications to include any annotations / constraints / etc.); always helps to be able to fetch the source of truth for the schema as it's pretty easy to lose track of queries that have been run. Might help to meet in the middle with regards to the old type browser functionality.
You're right, thanks! We'll be working on docs for additions and refinements for quite some time, so all questions and suggestions are always welcome.
The manual is not yet complete (but will be ready next week). We have a dedicated manual section for Reads, and these examples from the TypeQL docs can have a good representation over there, too 🙂 cc @Joshua @christoph.dorn
We are also working on the best ways to retrieve schemas, so we'll keep you updated
Doesn't seem to work in TypeDB Studio
^ I just ran that in the latest typedb studio with typedb 3.0.2, on the schema from crash course
@georgii good stuff thanks! Look forward to reading it.
Btw,
select
is unnecessary in your case as you only have these two variables. It will make the query shorter 🙂
You probably don't have any entity types in your schemaI've one entity for sure
Sorry, you don't have entities or
sub
s between them
Empty sets in type inference are considered errors in 3.0.2, but it may change to 0 answers in the futureI've tested with the most simple schema:
Yes, and this schema does not have
sub
s. In 3.0, the entity employee
declaration does not produce any subtypingbut this works:
yes
entity
, relation
, attribute
are now kinds definition keywords
So your schema is empty by default, no strange abstract entity
entities and stuff 🙂So what is the best commands to get the schema ? Empty or not ?
Please follow the get started section with the crash course to get a better feeling of 3.0, I'm sure everything will get clearer! https://typedb.com/docs/home/get-started
For now, you're unable to get the whole schema with everything declared in it. But you can use
match
to get entity types, relation types, attribute types, role types (relates
, type traits (owns
, plays
), subtyping information (sub
), value types of the attribute types (value
), etc. Unfortunately, not a single lineok... and select is not recognized as a typeql keyword btw
@alex Haven't we updated TypeQL in Studio?
let's discuss in person when you're available?