Google Firebase OrderByChild无法使用嵌套动态键

时间:2016-09-01 14:48:17

标签: javascript firebase firebase-realtime-database

当动态键介于实际参考和数据之间时,按子(名称)排序不起作用。

这是我的代码:

firebase.database().ref('/usersProfile').orderByChild('name').on('value', function(snapshot) {
  callback(snapshot);
});
callback(snapshot) {
  //console.log(snapshot);
  let data = snapshot.val();
  self.users = [];
  for(let key in data) {
    let value = data[key];
    value.categId = key;
    self.users.push(value);
  }
}

这是我通过服务器收集的数据:

enter image description here

1 个答案:

答案 0 :(得分:2)

我认为你的正斜线可能是问题所在。它应该看起来像这样:

root@wb01-development [/home/example/public_html/node]# cat /usr/local/apache/conf/userdata/ssl/2_4/example/example.com/example_ssl_node.conf
  <VirtualHost 132.159.25.21:443>
    ServerName node.example.com
    ServerAlias www.node.example.com
    DocumentRoot /home/example/public_html/node
    ServerAdmin webmaster@example.com
    UseCanonicalName Off

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full
    SSLProxyEngine On
    ProxyPass / https://node.example.com:3030/
    ProxyPassReverse / https://node.example.com:3030/

    CustomLog /usr/local/apache/domlogs/nodessl.example.com combined
    <IfModule log_config_module>
      <IfModule logio_module>
        CustomLog /usr/local/apache/domlogs/nodessl.example.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
      </IfModule>
    </IfModule>
    ## User example # Needed for Cpanel::ApacheConf
    <IfModule userdir_module>
      <IfModule !mpm_itk.c>
        <IfModule !ruid2_module>
          UserDir enabled example
        </IfModule>
      </IfModule>
    </IfModule>

    # Enable backwards compatible Server Side Include expression parser for Apache versions >= 2.4.
    # To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
    # the user's .htaccess file.  For more information, please read:
    #    http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
    <IfModule include_module>
      <Directory "/home/example/public_html/node">
        SSILegacyExprParser On
      </Directory>
    </IfModule>

    <IfModule suphp_module>
      suPHP_UserGroup example example
    </IfModule>
    <IfModule !mod_disable_suexec.c>
      <IfModule !ruid2_module>
        SuexecUserGroup example example
      </IfModule>
    </IfModule>
    <IfModule ruid2_module>
      RMode config
      RUidGid example example
    </IfModule>
    <IfModule mpm_itk.c>
      # For more information on MPM ITK, please read:
      #   http://mpm-itk.sesse.net/
      AssignUserID example example
    </IfModule>

    <IfModule alias_module>
      ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/
    </IfModule>
    <IfModule ssl_module>
      SSLEngine on

      SSLCertificateFile /var/cpanel/ssl/installed/certs/_wildcard__example_com_c1ebe_c4ca7_1483487999_2becd0f081b8814a3dc006e99fb0f972.crt
      SSLCertificateKeyFile /var/cpanel/ssl/installed/keys/c1ebe_c4ca7_2d88c428bbeef56e18aa682d1b3a0ed2.key
      SSLCACertificateFile /var/cpanel/ssl/installed/cabundles/GeoTrust_Inc__1b5858b431d25fcb2b55fda3f4e11447_1653082610.cabundle
      CustomLog /usr/local/apache/domlogs/nodessl.example.com-ssl_log combined
      SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
      <Directory "/home/example/public_html/cgi-bin">
        SSLOptions +StdEnvVars
      </Directory>
    </IfModule>

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/ssl/2_4/example/example.com/*.conf"
  </VirtualHost>