如何加载分数高于100的最新帖子?

Cod*_*000 11 javascript firebase firebase-realtime-database

情况:

我目前使用以下代码按时间顺序加载最新帖子:


码:

        $scope.data = [];
        var _n = Math.ceil(($(window).height() - 50) / (350)) + 1;
        var _start = <%= lastID %>;
        var firstElementsLoaded = false;

        $scope.getDataset = function() {

            fb.orderByChild('id').startAt(_start).limitToFirst(_n).on("child_added", function(dataSnapshot) {

                _start = dataSnapshot.child("id").val() + 1;
                console.log("LAST TRUE ID:"+ _start);

                $scope.data.push(dataSnapshot.val());
                $scope.$apply()
                console.log("THE VALUE:"+$scope.data);

                firstElementsLoaded = true;
            });
        };


        $scope.getDataset();
Run Code Online (Sandbox Code Playgroud)

题:

我应该如何修改它基本上具有完全相同的行为,但只根据按时间顺序查询分数大于100的帖子?


更新:

我终于找到了一种方法来使用我的架构"创建另一个索引"方法.但仍存在一个障碍:

如何将childNode从一个节点复制到另一个节点?

Cod*_*000 3

我重新思考了我的架构,并为热门帖子创建了一个特定的索引:

if (funPost.score >= global.hotNumber && funPost.hot == false) {
            var hotPostRef = firebase.database().ref("hot/section/"+key);
            var hotPost = {
                title: funPost.title,
                image: funPost.image,
                id: funPost.id,
                key: funPost.key
            }
            hotPostRef.set(hotPost);
            funPostRef.update({"hot": true});
        }
   else if (funPost.score <= (global.hotNumber - 25) && funPost.hot == true) {
        var hotPostRef = firebase.database().ref("hot/section/"+key);
        hotPostRef.remove();
        funPostRef.update({"hot": false});
   }
Run Code Online (Sandbox Code Playgroud)