Skip to content

Instantly share code, notes, and snippets.

@diyism
Created November 29, 2012 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diyism/4167554 to your computer and use it in GitHub Desktop.
Save diyism/4167554 to your computer and use it in GitHub Desktop.
Firebase Feature reqeust: asynchronous trigger and access control
A simple use case about firebase trigger:
I have a stocks table(tb_stocks):
GoodsID,GoodsNum,Quantity
1,KK0245MM08-804-M,98
2,KK0172YY02-990-L,18
3,KK2104MM681-990-XXL,20
And an orders table(tb_orders):
OrderID,UserName,GoodsID,Quantity,CreateTime
1,Andy,3,1,2012-11-29 11:01:01
2,Bob,2,1,2012-11-29 11:02:01
I very much desire a trigger feature in Firebase:
When a user make an order from his/her mobile phone, for example, a new line inserted into orders table:
3,Jack,2,1
then the trigger function will decrease KK0172YY02-990-L's stock quantity from 18 to 17.
If my shopping app is very popular, i will need a asynchronous trigger that at every 5 minutes summarize all orders in 5 minutes:
1,Jack,3,1,2012-11-29 11:01:00
2,Evan,3,2,2012-11-29 11:04:00
The updates of stocks table will be triggered only once at 11:05:00, the KK2104MM681-990-XXL's quantity will be updated from 20 to 17.
The user will be verified by Firebase,
and a user can insert data into the orders table through my mobile app(with ajax actions), //TABLE LEVEL INSERT privilege allowed
a user is not allowed to access stocks table, //TABLE LEVEL ALL privilege denied
a user can modify the hashed password in the row of users table(tb_users): //ROW LEVEL UPDATE, TABLE LEVEL INSERT privileges allowed
UserID,Username,Hash
1,Jack,2c7a6c784d9d8cdd9cf5c4f3bb9a0dfd
2,Peter,05e66fbd3725a7cf2de8535a64b24da7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment