Ref
Ref( schema_ref, id )
Ref( schema_ref, id )
Ref( schema_ref, id )
Ref( schema_ref, id )
ref( schema_ref, id )
Ref( schema_ref, id )
Description
The Ref
function returns the reference for a specific document, based
on the provided id
, within a specific database, implicitly based on
the schema_ref
. Typically, this would be used to get the reference for a
user document in a collection.
Everything in Fauna is described by a document. The documents that describe fundamental Fauna infrastructure are created by the system and are called schema documents, or core schemas. Any other documents are user-created, and are called user documents.
References are like primary keys in other database systems, in that they are used to provide a pointer to a unique document.
References to core schema documents, that you pass in via schema_ref
,
are provided by their respective functions:
The Ref command does not verify that 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
Argument | Type | Definition and Requirements |
---|---|---|
|
Ref |
A reference to a specific schema document to which the desired document belongs. |
|
String |
The identifier for the specific reference. |
Examples
The following query returns the reference to a specific document in the "spells" collection:
client.Query(
Ref(Collection("spells"), "181388642046968320")
);
RefV(id = "181388642046968320", collection = RefV(id = "spells", collection = RefV(id = "collections")))
result, err := client.Query(
f.Ref(f.Collection("spells"), "181388642046968320"))
if err != nil {
fmt.Fprintln(os.Stderr, err)
} else {
fmt.Println(result)
}
{181388642046968320 0xc000160150 0xc000160150 <nil>}
System.out.println(
client.query(
Ref(Collection("spells"), "181388642046968320")
).get()
);
ref(id = "181388642046968320", collection = ref(id = "spells", collection = ref(id = "collections")))
client.query(
q.Ref(q.Collection('spells'), '181388642046968320')
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
Ref(Collection("spells"), "181388642046968320")
result = client.query(
q.ref(q.collection("spells"), "181388642046968320")
)
print(result)
Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections)))
client.query(
Ref(Collection("spells"), "181388642046968320")
)
ref(id = "181388642046968320", collection = ref(id = "spells", collection = ref(id = "collections")))
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!