Classes

Classes( [database] )
Classes( [database] )
Classes( [database] )
Classes( [database] )
classes( [database] )
Classes( [database] )

Description

This function is deprecated as of Fauna 2.7.0. Use Collections instead.

A Class was renamed to a Collection in Fauna 2.7.0. This function continues to exist for compatibility with older drivers.

The Classes function, when executed with Paginate, returns an array of References for all classes (now, collections) in the child database specified. If a child database is not specified, the returned class (now, collection) references all belong to the current database.

When a child database is specified, an admin key must be used to call Classes (server or client keys, or ABAC tokens, cannot be used to access a child database).

Parameters

Argument Type Definition and Requirements

database

Optional - A reference to a child database. If not specified, the current database is used.

Returns

A Set reference for the available classes (now, collections) in the specified child database (or the current database if database is not specified).

Examples

The following query gets the references to all classes (now, collections) within the current database:

client.Query(
    Paginate(Collections())
);
ObjectV(data: Arr(RefV(id = "Letters", collection = RefV(id = "collections")), RefV(id = "People", collection = RefV(id = "collections")), RefV(id = "characters", collection = RefV(id = "collections")), RefV(id = "customers", collection = RefV(id = "collections")), RefV(id = "decrepit_huts", collection = RefV(id = "collections")), RefV(id = "magical_creatures", collection = RefV(id = "collections")), RefV(id = "orders", collection = RefV(id = "collections")), RefV(id = "posts", collection = RefV(id = "collections")), RefV(id = "products", collection = RefV(id = "collections")), RefV(id = "spellbooks", collection = RefV(id = "collections")), RefV(id = "spells", collection = RefV(id = "collections")), RefV(id = "storehouses", collection = RefV(id = "collections")), RefV(id = "users", collection = RefV(id = "collections"))))
result, err := client.Query(
	f.Paginate(f.Collections()))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[{Letters 0xc00008e240 0xc00008e240 <nil>} {People 0xc00008e330 0xc00008e330 <nil>} {characters 0xc00008e420 0xc00008e420 <nil>} {customers 0xc00008e510 0xc00008e510 <nil>} {decrepit_huts 0xc00008e600 0xc00008e600 <nil>} {magical_creatures 0xc00008e6f0 0xc00008e6f0 <nil>} {orders 0xc000184000 0xc000184000 <nil>} {posts 0xc0001840f0 0xc0001840f0 <nil>} {products 0xc0001841e0 0xc0001841e0 <nil>} {spellbooks 0xc0001842d0 0xc0001842d0 <nil>} {spells 0xc0001843c0 0xc0001843c0 <nil>} {storehouses 0xc0001844b0 0xc0001844b0 <nil>} {users 0xc0001845a0 0xc0001845a0 <nil>}]]
System.out.println(
    client.query(
        Paginate(Collections())
    ).get());
{data: [ref(id = "Letters", collection = ref(id = "collections")), ref(id = "People", collection = ref(id = "collections")), ref(id = "characters", collection = ref(id = "collections")), ref(id = "customers", collection = ref(id = "collections")), ref(id = "decrepit_huts", collection = ref(id = "collections")), ref(id = "magical_creatures", collection = ref(id = "collections")), ref(id = "orders", collection = ref(id = "collections")), ref(id = "posts", collection = ref(id = "collections")), ref(id = "products", collection = ref(id = "collections")), ref(id = "spellbooks", collection = ref(id = "collections")), ref(id = "spells", collection = ref(id = "collections")), ref(id = "storehouses", collection = ref(id = "collections")), ref(id = "users", collection = ref(id = "collections"))]}
client.query(
  q.Paginate(q.Collections())
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
{
  data: [
    Collection("Letters"),
    Collection("People"),
    Collection("characters"),
    Collection("customers"),
    Collection("decrepit_huts"),
    Collection("magical_creatures"),
    Collection("orders"),
    Collection("posts"),
    Collection("products"),
    Collection("spellbooks"),
    Collection("spells"),
    Collection("storehouses"),
    Collection("users")
  ]
}
result = client.query(
    q.paginate(q.collections())
)
print(result)
{'data': [Ref(id=Letters, collection=Ref(id=collections)), Ref(id=People, collection=Ref(id=collections)), Ref(id=characters, collection=Ref(id=collections)), Ref(id=customers, collection=Ref(id=collections)), Ref(id=decrepit_huts, collection=Ref(id=collections)), Ref(id=magical_creatures, collection=Ref(id=collections)), Ref(id=orders, collection=Ref(id=collections)), Ref(id=posts, collection=Ref(id=collections)), Ref(id=products, collection=Ref(id=collections)), Ref(id=spellbooks, collection=Ref(id=collections)), Ref(id=spells, collection=Ref(id=collections)), Ref(id=storehouses, collection=Ref(id=collections)), Ref(id=users, collection=Ref(id=collections))]}
client.query(Paginate(Collections()))
{data: [ref(id = "Letters", collection = ref(id = "collections")), ref(id = "People", collection = ref(id = "collections")), ref(id = "characters", collection = ref(id = "collections")), ref(id = "customers", collection = ref(id = "collections")), ref(id = "decrepit_huts", collection = ref(id = "collections")), ref(id = "magical_creatures", collection = ref(id = "collections")), ref(id = "orders", collection = ref(id = "collections")), ref(id = "posts", collection = ref(id = "collections")), ref(id = "products", collection = ref(id = "collections")), ref(id = "spellbooks", collection = ref(id = "collections")), ref(id = "spells", collection = ref(id = "collections")), ref(id = "storehouses", collection = ref(id = "collections")), ref(id = "users", collection = ref(id = "collections"))]}

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!