ios - Firebase iOS SDK : How to get multiple Data in one query
<p><p>我见过 <a href="https://stackoverflow.com/questions/35720686/how-to-retrieve-multiple-data-in-one-query-firebase" rel="noreferrer noopener nofollow">how to retrieve multiple data in one query firebase</a>所以这可能是一个类似的问题,但我是 Firebase 的新手,我没有正确理解。</p>
<p>这是我的情况:</p>
<p>我有一个这样的 Firebase 数据库:
<img src="/image/oMASy.png" alt="Database structure"/> </p>
<p>我想检索参与特定事件的用户。<br/>
<strong>编辑</strong><br/>
我试过了,<br/></p>
<pre><code>Firebase* childrens = ;
Firebase* firebaseUser = ;
Firebase* firebaseEvent = ;
Firebase* fbuser= ;
FQuery* query1 = ;
handleFirebase = [query1 observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot){
NSEnumerator* childrens = snapshot.children;
[childrens.allObjects enumerateObjectsUsingBlock:^(FDataSnapshot* rootSnap,NSUInteger rootIndex,BOOL* rootStop){
NSDictionary* rootData = rootSnap.value;
NSString* rootKey = rootSnap.key;
NSLog(@"\nRootKey: %@\nRootData: %@",rootKey,rootData);
}];
</code></pre>
<p><br/>
这里是 <code>NSLog</code> <br/></p>
<pre><code>2016-03-10 15:27:23.399 SquadApp
RootKey: olbuzevent1
RootData: {
createdTime = "2016-03-08T11:53:33Z";
name = "OLBUZ event 1";
participents = {
"335e63c9-46c6-4ff8-99e7-1537d99731f7" = {
id = "335e63c9-46c6-4ff8-99e7-1537d99731f7";
joinnedTime = 0;
};
};
}
2016-03-10 15:27:24.150 SquadApp
RootKey: olbuzevent2
RootData: {
createdTime = "2016-03-08T12:23:28Z";
name = "OLBUZ event 2";
participents = {
"335e63c9-46c6-4ff8-99e7-1537d99731f7" = {
id = "335e63c9-46c6-4ff8-99e7-1537d99731f7";
joinnedTime = 0;
};
};
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 NoSQL 数据库中,您通常必须按照您希望在应用程序中使用数据的方式对数据进行建模。您当前的结构非常适合显示用户组织/参与的事件列表。如果这是您的用例之一,那就太好了。</p>
<p>但是,如果您还有一个用例来显示参与事件的所有用户,您可能必须添加一个数据结构来跟踪它。</p>
<pre><code>event_users
eventid1
uid1: 'participant'
uid2: 'organizer'
uid3: 'participant'
</code></pre>
<p>这个过程被称为非规范化,在我们的一个(相当老的)<a href="https://www.firebase.com/blog/2013-04-12-denormalizing-is-normal.html" rel="noreferrer noopener nofollow">blog posts</a> 中进行了介绍。在 <a href="https://www.firebase.com/docs/android/guide/structuring-data.html#section-indices" rel="noreferrer noopener nofollow">documentation on structuring data</a> .在最后一页中,您可能还应该阅读 <a href="https://www.firebase.com/docs/android/guide/structuring-data.html#section-nested" rel="noreferrer noopener nofollow">recommendation on nesting</a> .</p></p>
<p style="font-size: 20px;">关于ios - Firebase iOS SDK : How to get multiple Data in one query,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/35912819/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/35912819/
</a>
</p>
页:
[1]