0

hero.ts

export class Hero {
  name: string;
  timestamp: number;
  negativeTimestamp: number;

  constructor() {
    this.name = '';
    this.timestamp = firebase.database['ServerValue']['TIMESTAMP'];
    this.negativeTimestamp = 0 - firebase.database['ServerValue']['TIMESTAMP'];
  }

}

It throws error when I create an object from this class using new Hero(); The error message is

EXCEPTION: Uncaught (in promise): Error: Firebase.push failed: first argument contains NaN in property 'heroes.zeNtSMyJGvdZkMcxXsdfwSsbmSBrv2.negativeTimestamp'

this.timestamp works. It generated a timestamp value in Firebase database. That is correct. But how to get a negativeTimestamp?

My objective is to make timestamp from positive value to negative timestamp value. It's for using firebase descending ordering purpose.

adjuremods
  • 2,870
  • 2
  • 11
  • 16
Jek
  • 5,325
  • 6
  • 33
  • 64

0 Answers0