Issue with "storeAs" for a single document in subcollection
See original GitHub issueDo 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:
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:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You may want to try out the
v1.0.0
pre-releases available through thealpha
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 needingstoreAs
.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
Change
storeAs
topath
and this does what you want.storeAs: 'properties/${propertyId}'
→path: 'properties/${propertyId}'
⚠️Warningpath
doesn’t seem to appear in the docs so it could disappear or break in future.