Getting fields out of Refs with Get

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet

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.

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

Instructor: [00:00] When working with FQL, it is often the case that you'll get a rec2 document or other type to deal with. For example, if we use the collections function, we get a ref to the collections.

[00:11] If we select a specific collection, we get a ref to the collection customers. 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.

[00:33] That's where Get comes in. The Get function will retrieve the value of the ref. 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 a specific collection. The object for our collection includes history days, which is the number of days until the history gets deleted.

[00:54] Get is an important tool in your toolset when working with FQL.