如何从子

时间:2018-02-21 20:40:41

标签: javascript firebase firebase-realtime-database

如何从firebase获取最后20条记录?我得到了:

  

数据集:undefined undefined

我的firebase看起来像这样:

firebase

我的代码

var rootRefData = db.ref().child("users_db/user1/dataset");
rootRefData.once("value", snap => {
    var key = snap.key;
    var timestamp = snap.val().timestamp;
    var log = snap.val().log;
    var custom = "";

    // create line chart
    custom += key + ": " + timestamp + " " + log + "<br />";
    console.log(custom);

    counter++;
    $("#chartsl-container-all").append(custom);
});

1 个答案:

答案 0 :(得分:1)

试试这个:

npy_intp stride = PyArray_STRIDE(pArray, 0);
const char * dataptr = PyArray_BYTES(pArray);
PyObject * p1 = PyArray_GETITEM(pArray, dataptr);
PyObject * p2 = PyArray_GETITEM(pArray, dataptr + stride);

var rootRefData = db.ref().child("users_db/user1/dataset"); rootRefData.once("value", snap => { snap.forEach(function (snapshot) { var key = snapshot.key; var timestamp = snapshot.val().timestamp; var log = snapshot.val().log; var custom = ""; 位于节点数据集中,因为您想要获取时间戳和日志,然后您需要使用rootRefData在randomid内部迭代,以便能够获取这些值和随机ID。