0

Hi I am new to firebase firestore And I can't add object directly into the collection see the image wrong result and expected result

Tried

 admin.firestore()
        .collection('/user/DVCeb96fLKNAeVo1YIbukAOWMI12/balance/')
        .doc()
        .set(userBalance)

It creating a new document under balance collection but I need its Object value directly inside the balance collection

cakePHP
  • 425
  • 1
  • 4
  • 23

1 Answers1

1

This is unfortunately not possible in Firestore. The documentation specifies that the only possible structure is (for this case):

Collection -> Document -> Doc Info

You will have to have some document under the collection, however, you also have the option of using the 'Realtime Database', which is a little different, but will allow this.

If you insist on using Firestore then I recommend setting a global constant (some String to describe the document name), and using that to access the info in the doc.

R.S.
  • 146
  • 2