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.

Firestore nested collections

See original GitHub issue

hello eddy,

first of all thx for this amazing plugin!

I am trying to use the new firestore feature. The firebase docs are saying that yon can nest a collection under a document ref. Using your plugin the nesting doesn´t work. The collection is always being created under the root of the database.

Here my example code

let userDoc = firestore.collection('users').doc(user.uid);
userDoc.set({email: user.email});
userDoc.collection('worktimes').doc(data.key).set({
    date: data.value.date,
    reverseOrderDate: data.value.reverseOrderDate,
    workTimeEnd: data.value.workTimeEnd,
    workTimeStart: data.value.workTimeStart,
    workingMinutesBrutto: data.value.workingMinutesBrutto,
    workingMinutesNetto: data.value.workingMinutesNetto,
    workingMinutesOverTime: data.value.workingMinutesOverTime,
    workingMinutesPause: data.value.workingMinutesPause
});

I´m expecting the worktimes data under the user document but in the firebase console there is a collection “worktimes” at the root level.

The data comes from an api call. Any ideas? Thx Armin

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ITServicesAMcommented, Dec 6, 2017

no one?

1reaction
ITServicesAMcommented, Dec 7, 2017

I think I found the problem, in firebase.android.ts you are creating a collection from the root db instance everytime. If I don´t chain the collection.doc.collection calls instead get the collection with a deeplink (users/${user.uid}/worktimes) it works.

We need to find a way to determan if the collection is a chained one or the root one. If chained generate the path relative to the document otherwise generate the path from the root db.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Firestore documents in nested collections | Google Cloud
Get Firestore documents in nested collections. bookmark_border. Stay organized with collections Save and categorize content based on your preferences.
Read more >
Cloud Firestore Data model - Firebase
Documents can contain subcollections and nested objects, both of which can include primitive fields like strings or complex objects like lists. Collections and ......
Read more >
How to use Nested Collections in cloud firestore - YouTube
In this video, you'll learn:- 1. Why use NestedCollections instead of arrays? 2. How to create a collection inside a document?
Read more >
Firestore: Query multiple nested collections - Stack Overflow
To read from all events-collection collections in one go, you can use a collection group query. For example, without any conditions, ...
Read more >
Creating and querying nested collections in Firebase
const currentUser = firebase.auth().currentUser.uid; const eventsRef = firebase.firestore().collection('events'); · const documentId = document.
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