FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard. For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions. |
Ref
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Ref( schema_ref, document_id )
ref( schema_ref, document_id )
Ref( schema_ref, document_id )
Ref( schema_ref, document_id )
Ref( schema_ref, document_id )
Ref( schema_ref, document_id )
Description
The Ref
function is used to express the reference for a
specific document that exists in the current database, within the
schema_ref
, having the document ID document_id
.
References serve the same purpose as primary keys in other database systems: they are used to provide a pointer to a specific document.
The schema_ref
is a reference to a specific collection of documents.
Everything in Fauna is described by a document. The documents that
describe fundamental Fauna infrastructure are called schema
documents, or core schemas. Any other documents are user-created, and
are called user documents.
References to core schema documents, that you pass in via schema_ref
,
are provided by their respective functions:
The This feature is particularly useful when creating parent-child relationships. The parent record can be created with a list of non-existent child references before the child records are created. You have to use this feature carefully or queries that use such references could fail. |
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Reference |
A Reference to a specific schema document to which the desired document belongs. |
|
String |
A document identifier, which is a string-encoded 64-bit integer. |
Examples
The following query returns the reference to a specific document in the "spells" collection:
Ref(Collection("spells"), "181388642046968320")
Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections)))
{181388642046968320 0xc000160150 0xc000160150 <nil>}
RefV(id = "181388642046968320", collection = RefV(id = "spells", collection = RefV(id = "collections")))
ref(id = "181388642046968320", collection = ref(id = "spells", collection = ref(id = "collections")))
Ref(Collection("spells"), "181388642046968320")
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!