firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.84k stars 889 forks source link

FR: Expose DocumentReference.create on Web #6707

Open danielzgtg opened 2 years ago

danielzgtg commented 2 years ago

I would like to create a document from the browser using behaviour similar to O_CREAT | O_EXCL. 8 other people are also looking for a clean way to do this. This functionality is present in the REST API, it's just not exposed to the JavaScript SDK.

This differs from #1795 in that I'm not using any testing or admin SDK. They found a workaround. I also found a workaround, but I am creating this feature request because that workaround feels like a code smell.

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Steps to reproduce:

  1. Open https://firebase.google.com/docs/reference/js/firestore_.documentreference
  2. https://firebase.google.com/docs/reference/js/v8/firebase.firestore.DocumentReference
  3. CTRL-F for "create"
  4. Find no actual "create" method

Relevant Code:

This problem is apparent at the documentation level, not the code level.

dconeybe commented 2 years ago

Hi @danielzgtg. Thank you for reporting this feature request. I'll talk with the team about it.

In the meantime, Have you considered using transactions to get this behavior? https://firebase.google.com/docs/reference/js/firestore_#runtransaction