12

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

Achaius
  • 5,904
  • 21
  • 65
  • 122

1 Answers1

6

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"))

benjumanji
  • 1,395
  • 7
  • 15