FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, review the migration guide. Contact support@fauna.com with any questions.

Classes

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Classes( [database] )
classes( [database] )
Classes( )
ScopedClasses( 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).

Also, Go does not support optional function parameters, nor function overloading. To specify a child database using the Go driver, call the ScopedClasses function instead of Classes.

Parameters

Parameter Type Definition and Requirements

database

Reference

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

A Reference to a child database.

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

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

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

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

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

  1. The following query lists the References for any classes (now, collections) (up to the pagination limit) within the current database:

    client.query(
      q.Paginate(q.Classes())
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error(
      'Error: [%s] %s: %s',
      err.name,
      err.message,
      err.errors()[0].description,
    ))
    {
      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("stores"),
        Collection("users")
      ]
    }
    result = client.query(
        q.paginate(q.classes())
    )
    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=stores, collection=Ref(id=collections)), Ref(id=users, collection=Ref(id=collections))]}
    result, err := client.Query(
    	f.Paginate(f.Classes()))
    
    if err != nil {
    	fmt.Fprintln(os.Stderr, err)
    } else {
    	fmt.Println(result)
    }
    map[data:[{Letters 0xc000156180 0xc000156180 <nil>} {People 0xc000156270 0xc000156270 <nil>} {characters 0xc000156360 0xc000156360 <nil>} {customers 0xc000156450 0xc000156450 <nil>} {decrepit_huts 0xc000156540 0xc000156540 <nil>} {magical_creatures 0xc000156630 0xc000156630 <nil>} {orders 0xc00008e150 0xc00008e150 <nil>} {posts 0xc00008e240 0xc00008e240 <nil>} {products 0xc00008e330 0xc00008e330 <nil>} {spellbooks 0xc00008e420 0xc00008e420 <nil>} {spells 0xc00008e510 0xc00008e510 <nil>} {stores 0xc00008e600 0xc00008e600 <nil>} {users 0xc00008e6f0 0xc00008e6f0 <nil>}]]
    try
    {
        Value result = await client.Query(
            Paginate(Classes())
        );
        Console.WriteLine(result);
    }
    catch (Exception e)
    {
        Console.WriteLine($"ERROR: {e.Message}");
    }
    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 = "stores", collection = RefV(id = "collections")), RefV(id = "users", collection = RefV(id = "collections"))))
    Paginate(Classes())
    {
      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("stores"),
        Collection("users")
      ]
    }
    Query metrics:
    •    bytesIn:   29

    •   bytesOut:  937

    • computeOps:    1

    •    readOps:    8

    •   writeOps:    0

    •  readBytes:  754

    • writeBytes:    0

    •  queryTime: 15ms

    •    retries:    0

  2. The following query lists the References for any classes (now, collections) (up to the pagination limit) within a child database named "child_db":

    client.query(
      q.Paginate(q.Classes(q.Database('child_db')))
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error(
      'Error: [%s] %s: %s',
      err.name,
      err.message,
      err.errors()[0].description,
    ))
    { data: [] }
    result = client.query(
        q.paginate(q.classes(q.database("child_db")))
    )
    print(result)
    {'data': []}
    result, err := client.Query(
    	f.Paginate(f.ScopedClasses(f.Database("child_db"))))
    
    if err != nil {
    	fmt.Fprintln(os.Stderr, err)
    } else {
    	fmt.Println(result)
    }
    map[data:[]]
    try
    {
        Value result = await client.Query(
            Paginate(Classes(Database("child_db")))
        );
        Console.WriteLine(result);
    }
    catch (Exception e)
    {
        Console.WriteLine($"ERROR: {e.Message}");
    }
    ObjectV(data: Arr())
    Paginate(Classes(Database('child_db')))
    { data: [] }
    Query metrics:
    •    bytesIn:   48

    •   bytesOut:   24

    • computeOps:    1

    •    readOps:    8

    •   writeOps:    0

    •  readBytes:  363

    • writeBytes:    0

    •  queryTime: 10ms

    •    retries:    0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!