Thanks for the tipp! I found a nice example by Vikrum linked from
http://stackoverflow.com/questions/16127389/real-time-click-link-counter
. (The actual code for the transactional counter is amazingly short,
nice API :) )
The above is useful for generating unique IDs for various uses.
Regarding the IDs set on push etc (per object / DB record):
Perhaps it would make sense to offer a setting per Firebase, where
(before the Firebase gets used) the developer can choose between two
options:
A) The IDs are available immediately and are highly unlikely to collide.
B) The IDs are available after a short lag (server roundtrip latency)
but are guaranteed to never collide. (They first ID could be "1".)
Option A is how it currently works AFAIK, and option B could be offered
as alternative in the future.
Tobi
--
http://tobireif.com
On 7/12/13 8:06 PM, Andrew Lee wrote:
> You actually can generate guaranteed-unique auto-incrementing numbers
> already. You just need to use a transaction() on a counter. Increment it
> each time you want a new ID.
>
> -Andrew
>
>
> On Thu, Jul 11, 2013 at 1:46 AM, Tobi Reif <
to...@tobireif.com
> <mailto:
to...@tobireif.com>> wrote:
>
> It makes sense to generate an ID on the client in order to provide
> it immediately / avoid waiting for network latency/roundtrip.
>
> But in case where the scenario calls for absolutely unique IDs,
> Firebase could offer an alternative where IDs can be requested and
> are provided by the server, 100% unique per app / Firebase. (It
> could simply start with a "1".)
>
> The developer could (per app) decide between fast and unlikely to
> collide vs a bit slower and unique (100% unique per app).
>
> (I'm referring to IDs used for each message (
snapshot.name
> <
http://snapshot.name>() ) and the case where push() is used to get
> an email to firebase-talk+unsubscribe@__
googlegroups.com
> <mailto:
firebase-talk%2Bunsu...@googlegroups.com>.
> <mailto:
fireba...@googlegroups.com>__.
> For more options, visit
>
https://groups.google.com/__groups/opt_out
> <
https://groups.google.com/groups/opt_out>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Firebase Google Group" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to firebase-talk+unsubscribe@__
googlegroups.com
> <mailto:
firebase-talk%2Bunsu...@googlegroups.com>.
> <mailto:
fireba...@googlegroups.com>__.
> For more options, visit
https://groups.google.com/__groups/opt_out
> <
https://groups.google.com/groups/opt_out>.
> --
> You received this message because you are subscribed to the Google
> Groups "Firebase Google Group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
firebase-tal...@googlegroups.com.