skip to Main Content

Can I query the Realtime Database using the startAt filter together with serverTimestamp()?

If so, or if not, is this explicitly documented somewhere?

2

Answers


  1. Chosen as BEST ANSWER

    The answer appears to be no. Although I cannot find any documentation - I also cannot get code relying on serverTimestamp() to ever retrieve any information from the server when combined with listeners. I guess it's only for write operations.


  2. of course you can ,did you try anything yet ?

    only thing you need is to make sure you have some field value of timestamp in you doc so that during query you can use that to compare.

    import { serverTimestamp } from "firebase/firestore";
    import { ref } from "firebase/database";
    
    const db = getDatabase();
    const timeStamp=serverTimestamp();
    const ref = db.ref('server/saving-data/fireblog/posts');;
    const query = ref.orderByChild('timestamp').startAt(timeStamp);
    query.on('value', (snapshot) => {
      //do with the snapshot data here
    });
    

    see retrieve-data#range-queries

    please try and then let us know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search