Thursday 1 June 2017

Firebase database 10 records before actual

I have a database just like this:

epochs
   KPK_UYH
      1496347382000 < DYNAMICALLY STORED : TIMESTAMP 
         values
            volume: 255.14215282
            cheap: 0.00012000
            expensive: 0.00015622
      1496347447000
         values
            volume: 225.8
            cheap: 0.00019020
            expensive: 0.00025622
      1496355758000
         values
            volume: 272.14215282
            cheap: 0.00014028
            expensive: 0.00019622
   KQK_ZHN
      1496347382000
         values
            volume: 98.2
            cheap: 0.00000020
            expensive: 0.0000025
      1496347447000
         values
            volume: 99.4
            cheap: 0.00000034
            expensive: 0.00000039
      1496355758000
         values
            volume: 107.10
            cheap: 0.0000040
            expensive: 0.00000045

What i need to do is, after the current record is inserted, take the 'volume' property of the last two records, do some calculations and in another tree

just like this, for example:

the '1496355758000', just been inserted in the 'KQK_ZHN' tree, i need to get the 'volume' property from '1496347447000' and '1496347382000', and do some math accounts.

Someone has any idea how to do it?

I'm using nodejs.

thanks



via c0nf1ck

No comments:

Post a Comment