Refs and Get in FaunaDB

Chris Biscardi
InstructorChris Biscardi

Share this video with your friends

Send Tweet
Published 3 years ago
Updated a year ago

When working with FQL it's often the case that you'll encounter Refs. Refs don't have any fields on them though! So how do we access the fields? Get.

Ref(Collection("customers"), "244075679454331401")
Get(Ref(Collection("customers"), "244075679454331401"))

Instructor: [00:00] When working with FQL, it's often the case that you'll get a ref to a document that you have to deal with or other data type. For example, if we use the collections function, we get a ref to collections. If we select a specific collection, we get a ref to the collection customers.

[00:16] We can even build a ref to a specific document, using the ref to our customers collection, and the ID of the document. Whether constructing the ref ourselves, as in this case, or getting a set of refs from Paginate, you may be wondering where the fields on your documents are. That's where Get comes in. The Get function will retrieve the value of the ref.

[00:39] Note that now the result is the actual object, including the ref to the document and the data. We can see that this is also true for the specific collection. The object for our collection includes history days, which is the number of days before the history gets deleted. Get is an important tool in your tool set when working in FQL.