菜鸟教程小白 发表于 2022-12-11 18:38:04

ios - 应用过滤器和排序同一时间的firebase


                                            <p><div>
            <aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
      <div class="d-flex fd-column fw-nowrap">
            <div class="d-flex fw-nowrap">
                <div class="flex--item wmn0 fl1 lh-lg">
                  <div class="flex--item fl1 lh-lg">
                        <b>这个问题在这里已经有了答案</b>:
                        
                  <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果您在大多数情况下需要访问这些项目,这将是每个用户,您可以更改您的数据模型:</p>

<pre><code>{
&#34;user816&#34;: {
&#34;-KZVOY6qU29fJlRSwRNo&#34; : {
    &#34;fedStateDetails&#34; : &#34;Fasted&#34;,
    &#34;targetkcal&#34; : 596,
    &#34;timestamp&#34; : 1.482307285673975E9,
    &#34;workout_id&#34; : &#34;123&#34;
}
},
&#34;user47&#34;: {
&#34;-KZVSmeW94XetROs0nsN&#34; : {
    &#34;fedStateDetails&#34; : &#34;Fasted&#34;,
    &#34;targetkcal&#34; : 1874,
    &#34;timestamp&#34; : 1.482308270356936E9,
    &#34;workout_id&#34; : &#34;129&#34;
},
&#34;-KZWGdx-j1q7J37x0wck&#34; : {
    &#34;fedStateDetails&#34; : &#34;Fasted&#34;,
    &#34;targetkcal&#34; : 0,
    &#34;timestamp&#34; : 1.482321866382767E9,
    &#34;workout_id&#34; : &#34;40&#34;
}
}
}
</code></pre>

<p>现在您可以使用 <code>child()</code> 访问特定用户的数据,然后使用 <code>queryOrder(byChild:"timestamp")</code> 按时间戳对它们进行排序。</p>

<p>我推荐:</p>

<ul>
<li>阅读 <a href="https://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/" rel="noreferrer noopener nofollow">NoSQL data modeling</a> </li>
<li>查看<a href="https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s" rel="noreferrer noopener nofollow">Firebase for SQL developers</a> </li>
<li>研究我的答案 <a href="https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase" rel="noreferrer noopener nofollow">Query based on multiple where clauses in firebase</a> </li>
</ul></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 应用过滤器和排序同一时间的firebase,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41740178/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41740178/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 应用过滤器和排序同一时间的firebase