1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Getting fields out of Refs with Get

    Chris BiscardiChris Biscardi
    faunadbFaunaDB

    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"))
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 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.

    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.

    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.

    Get is an important tool in your toolset when working with FQL.