admin管理员组文章数量:1315950
I have the following problem. I try to manage a n to m structure with firebase. Therefore i made three collections.
collections
|-----cards
|----name
|----text
|-----cardlist
|----name
|----numberOfCards
|-----card_cardList
|----cardId
|----cardListId
|----number
Now I have the id of a cardList
and my goal is to get all the cards which are in this list. To get them from the card_list
collection i made this collection('card_list', q => q.where('cardListId', '==', myId)
.
After that i should somehow map the value number
with the cards values which I need to get somehow.
Does anyone have a suggestion how to do this?
Edited: card_cardList
is the collection which shows the n to m relation between cards and cardlist
I have the following problem. I try to manage a n to m structure with firebase. Therefore i made three collections.
collections
|-----cards
|----name
|----text
|-----cardlist
|----name
|----numberOfCards
|-----card_cardList
|----cardId
|----cardListId
|----number
Now I have the id of a cardList
and my goal is to get all the cards which are in this list. To get them from the card_list
collection i made this collection('card_list', q => q.where('cardListId', '==', myId)
.
After that i should somehow map the value number
with the cards values which I need to get somehow.
Does anyone have a suggestion how to do this?
Edited: card_cardList
is the collection which shows the n to m relation between cards and cardlist
-
What different between cardlist and card_list? Your name of the
collection
already so confused – Tony Bui Commented Jan 10, 2019 at 7:22 - I'm sorry for that. the cardlist is a collection which contains the information of the list like what's it's name, how many cards does it contain etc. The card_list is the n to m table between a card and a cardlist whit their id and an additional property – Yingrjimsch Commented Jan 10, 2019 at 7:41
- So you want to get all the cards which are in this list in a single go? Please responde with @AlexMamo – Alex Mamo Commented Jan 10, 2019 at 7:51
-
@AlexMamo yes thats the plan. I would like to get the card and the value
number
mapped. – Yingrjimsch Commented Jan 10, 2019 at 7:58
1 Answer
Reset to default 6According to the ments:
Q: So you want to get all the cards which are in this list in a single go?
A: Yes thats the plan.
You need to know that Firestore does not have any API to get documents from multiple collections in a single step. You will have to use two (or more) separate calls. In your particular case, you should create one to get the documents under cards
collection, and another one to get the documents in the cardlist
collection based on the relationship between them.
For more information, please also take a look at:
- Cloud Firestore - How to get relational data from two collections?
本文标签: javascriptHow do I get data from two collections in firestoreStack Overflow
版权声明:本文标题:javascript - How do I get data from two collections in firestore? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741995845a2410027.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论