title: How to update a document in Fauna without knowing the ref id
body: <p>I'm trying to update a document within a collection in Fauna, but I don't know the <code>ref</code> id besides looking in the database. I've been looking at this post: <a href="https://stackoverflow.com/questions/60594689/can-i-update-a-faunadb-document-without-knowing-its-id">Can I update a FaunaDB document without knowing its ID?</a> as I get the exact same error but I don't know exactly how to implement it into my own code.</p>
  <p>I'm trying to update a document containing a hairdresserId within data.</p>
  <pre><code>{
    &quot;ref&quot;: Ref(Collection(&quot;hairdressers&quot;), &quot;328130955075125442&quot;),
    &quot;ts&quot;: 1649343283790000,
   data: {
    &quot;hairdresserId&quot;: &quot;328027762241568962&quot;,
    }
  }
  </code></pre>
  <p>This is my API file:</p>
  <pre class="lang-js prettyprint-override"><code>import { updateJobProfileInfo } from &quot;@/utils/Fauna&quot;
  import { getSession } from &quot;next-auth/react&quot;
  
  export default async (req, res) =&gt; {
    const session = await getSession({ req })
    if (!session) return res.status(401)
  
    const hairdresserId = session.user.id
    if (req.method !== &quot;PUT&quot;) {
      return res.status(405).json({ msg: &quot;Method not allowed&quot; })
    }
  
    const {
      image,
      coverImage,
      bio,
      education,
      phone,
      email,
      status,
      preferences,
    } = req.body
  
    try {
      const updated = await updateJobProfileInfo(
        hairdresserId,
        image,
        coverImage,
        bio,
        education,
        phone,
        email,
        status,
        preferences
      )
      return res.status(200).json(updated)
    } catch (err) {
      console.error(err)
      res.status(500).json({ msg: &quot;Something went wrong.&quot; })
    }
    res.end()
  }
  
  </code></pre>
  <p>This is my fauna function:</p>
  <pre class="lang-js prettyprint-override"><code>const updateJobProfileInfo = async (
    hairdresserId,
    image,
    coverImage,
    bio,
    education,
    phone,
    email,
    status,
    preferences
  ) =&gt; {
    return await faunaClient.query(
      q.Update(q.Ref(q.Collection(&quot;hairdressers&quot;), hairdresserId), {
        data: {
          image,
          coverImage,
          bio,
          education,
          phone,
          email,
          status,
          preferences,
        },
      })
    )
  }
  </code></pre>
  <p>How can I update a document within my <code>hairdressers</code> collection when I don't have the <code>ref</code> but I know that the document contains <code>hairdresserId</code> ?</p>