Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141337

firebase Starting point was already set

$
0
0

I use firebase admin and realtime database on node.js Data look likeenter image description here

When I want to get data where batch = batch-7, I was doing

let batch = "batch-7";
let ref = admin.database().ref('qr/');
ref.orderByChild("batch").equalTo(batch).on('value', (snapshot) =>
    {
        res.json(Object.assign({}, snapshot.val()));
        ref.off();
    });

All was OK! But now i should create pagination, i.e. I should receive data on 10 elements depending on the page. I use this code:

let page = req.query.page;// num page
let batch = req.params.batch;// batch name
let ref = admin.database().ref('qr/');
ref.orderByChild("batch").startAt(+page*10).limitToFirst(10).equalTo(batch)
.on('value', (snapshot) =>
    {
        res.json(Object.assign({}, snapshot.val()));
        ref.off();
    });

But I have error:

Query.equalTo: Starting point was already set (by another call to startAt or equalTo)

How do I get data in the amount of N, starting at position M, where batch equal my batch


Viewing all articles
Browse latest Browse all 141337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>