Getting fields out of Refs with Get

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 years 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.

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.

egghead
egghead
~ 19 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today