Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch fields or schema of a FaunaDB class

Tags:

faunadb

Is it possible to fetch FaunaDB class schema or fields through fauna-shell or fauna-java API?

I am expecting fields and it datatypes for a given class or instance

like image 889
Achaius Avatar asked Aug 24 '18 12:08

Achaius


1 Answers

Fauna doesn't have schema enforcement baked into it, so the only way to know what fields are present on a particular class instance is to fetch that instance and inspect it. You can find example queries for loading instances in the FaunaDB documentation.

You can also run a query like (excuse my JavaScript, it would look slightly different in Java.) q.Paginate(q.Indexes()) -- this will list all the indexes in a database. And q.Paginate(q.Classes()) will list the classes. A query like q.Get(q.Class("greetings")) will load a particular classes schema, for indexes it looks like: q.Get(q.Index("all_greetings"))

like image 148
benjumanji Avatar answered Sep 22 '22 05:09

benjumanji