FQL.Schema.defForIdentifier()

Returns the document definition for a user-defined collection or user-defined function (UDF) using the same rules as top-level identifier lookups.

Signature

FQL.Schema.defForIdentifier(identifer: String) ⇒ Any

Description

FQL.Schema.defForIdentifier() returns the document definition for a user-defined collection or UDF using the same rules as top-level identifier lookups.

The lookup returns the first matching resource using the following precedence:

  1. A user-defined collection where .name == <IDENTIFIER>

  2. A user-defined collection where .alias == <IDENTIFIER>

  3. A UDF where .name == <IDENTIFIER>

  4. A UDF where .alias == <IDENTIFIER>

The document definition is an FQL version of the resource’s schema. See:

The method does not retrieve document definitions for system collections or other resources.

Parameters

Parameter Type Required Description

identifier

String

Yes

Identifier for a user-defined collection or UDF.

Return value

Type Description

Any

Document definition for the resource.

Examples

Get a user-defined collection’s document definition

// Gets the FQL schema for the `Product` collection.
FQL.Schema.defForIdentifier('Product')
{
  name: "Product",
  coll: Collection,
  ts: Time("2099-06-28T13:31:36.715Z"),
  indexes: {
    byName: {
      terms: [
        {
          field: ".name",
          mva: false
        }
      ],
      values: [
        {
          field: ".quantity",
          order: "desc",
          mva: false
        }
      ],
      queryable: true,
      status: "complete"
    },
    ...
  },
  ...
}

Get a UDF’s document definition

// Gets the FQL schema for the `inventory` UDF.
FQL.Schema.defForIdentifier('inventory')
{
  name: "inventory",
  coll: Function,
  ts: Time("2099-06-28T13:31:36.715Z"),
  role: "server",
  body: <<-END
    (name) => {
      Product.byName(name) {
        name: .name,
        description: .description,
        quantity: .quantity
      }

    }
  END
}

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!