question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with "storeAs" for a single document in subcollection

See original GitHub issue

Do you want to request a feature or report a bug?
bug

What is the current behavior? I want to store a subcollection “properties” of a user in the top level. It works as expected with the following code:

{
  collection: 'users',
  doc: uid,
  subcollections: [{ collection: 'properties' }],
  storeAs: 'properties',
}

But when I only need to fetch a single document from the subcollection “properties” and store it to the top level “properties”, the storeAs doesn’t work as expected with the code below:

{
  collection: 'users',
  doc: uid,
  subcollections: [{ collection: 'properties', doc: propertyId }],
  storeAs: `properties/${propertyId}`,
}

The single document is saved like this:

screen shot 2019-01-05 at 1 56 10 pm

What is the expected behavior?

I guess storeAs: `properties/${propertyId}` is wrong but what is the correct way to get around this? Thanks.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
prescottpruecommented, Jan 6, 2019

You may want to try out the v1.0.0 pre-releases available through the alpha tag since it stores subcollections along side top level collections by default and there are helpers for selecting from state based on your query without needing storeAs.

That said - I’m going to look into if there is a way to make that work with the current version, if not, there should be one added

0reactions
jake-nzcommented, Sep 28, 2020

Change storeAs to path and this does what you want. storeAs: 'properties/${propertyId}'path: 'properties/${propertyId}' ⚠️Warning path doesn’t seem to appear in the docs so it could disappear or break in future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

firestore data storing in sub collections - Stack Overflow
But I need to check if the document with a specific name is present under the chatRoomsMessages collection or not. Is there any...
Read more >
In Firestore, is it common to have subcollections that only store ...
So I created a subcollection that only has one document, which stores the large string value. This seems like it works, but it...
Read more >
Firestore get all sub collections - Libreria Lithos
To ensure a user can read their own stories only, you can set the ... Aug 26, 2013 · 10 Get data from...
Read more >
Getting data | Firestore - Google Cloud
Use a collection group query to retrieve results from a collection group instead of from a single collection. List subcollections of a document....
Read more >
Usage and limits | Firestore - Firebase
Maximum depth of subcollections, 100 ... The sum of the size of a document's single-field index entries; The sum of the size of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found