Home > Software design >  Property 'endBefore' does not exist on type 'Query'
Property 'endBefore' does not exist on type 'Query'

Time:01-08

My compiler is giving me the following error on this piece of code

  const snap = await admin
    .database()
    .ref(`schedule/${studentId}`)
    .orderByChild('start')
    .startAt(startDate)
    .endBefore(endDate)
    .once('value')

The error is

Property 'endBefore' does not exist on type 'Query'.

However, when looking at the firebase documentation (https://firebase.google.com/docs/reference/js/v8/firebase.database.Query) endBefore is a method on Query! What is going on with this?

CodePudding user response:

The endBefore operation was added in February 2021 to version 8.2.7 of the Firebase SDK for JavaScript/web. It was subsequently also added in May 2021 to version 9.8.0 of the Firebase Admin SDK for Node.js.

That is newer than the version you are using, so if you want to use endBefore you should upgrade to version 9.8 or later.

  •  Tags:  
  • Related