android - How to add a timestamp for when the Firebase object/node+subtree was modified? -


i'm looking create field storing timestamp of when object last changed. if of object's properties (aka subtree) modified, able set timestamp field current time.

firebase doesn't seem have way keep track of when object last updated. has implemented way in elegant fashion?

you can keep track of when node modified

root   users     user stuff   messages     messages   places_to_eat     places eat   timestamps     users: timestamp     messages: timestamp     places_to_eat: timestamp 

when data written users node, update timestamps node:

// ios / objectivec  firebase *userstimestampsref = [timestampsref childbyappendingvalue:"users"];  [userstimestampsref setvalue:kfirebaseservervaluetimestamp];   // android / java  firebase userstimestampsref = userstimestampsref.child("users");  userstimestampsref.setvalue(servervalue.timestamp); 

(you use timestamps/users well)

or, getting fancy, keep timestamp within node itself

root    users      timestamp: timestamp      user_list        user_1        user_2 

i have number of objc objects class objects handle reading , writing of data , automatically update timestamp when modified.

so example, have users class.

user auser = [userclass new] [auser createuser:"jay"] 

when createuser method called, inside class sets user , writes out username , updates timestamp accordingly. it's pretty seamless , low maintenance.

actually, parent class created heavy lifting , writing of timestamp of subclasses interact firebase inherit functionality.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -