Question with the ID field

33 views
Skip to first unread message

Eric Ponce

unread,
Apr 23, 2013, 12:02:17 PM4/23/13
to ged...@googlegroups.com
Hello!

When we create objects in geddy, these have one id field like: 6C45ABD6-8BF4-48B7-9E3A-BC92ADFACF66
It's unique or it's possible that another object has an equal id?

thanks!!!!

Miguel Madero

unread,
Apr 23, 2013, 12:06:00 PM4/23/13
to ged...@googlegroups.com
Generated GUIDs are guaranteed to be unique. Unless of course you explicitly copy the value from an existing one, since it's a primary key it should fail if you happen to do that.

 

Miguel


--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Eric Ponce

unread,
Apr 23, 2013, 12:09:07 PM4/23/13
to ged...@googlegroups.com
Thanks! Im only asking about new objects without any modifications. ;)

Miguel Madero

unread,
Apr 23, 2013, 12:20:39 PM4/23/13
to ged...@googlegroups.com
Yes, those ones will always be unique. Geddy will generate a different one of each object. 

There's some info about GUIDs in wikipedia, but the bottom line is that the algorithm used guarantees uniqueness across objects and computers in the network. 

Miguel

Miguel Madero

unread,
Apr 23, 2013, 12:20:48 PM4/23/13
to ged...@googlegroups.com

Eric Ponce

unread,
Apr 23, 2013, 12:26:01 PM4/23/13
to ged...@googlegroups.com
Wow thanks!!!

2^122 id's.....impossible repeat haha

Miguel Madero

unread,
Apr 23, 2013, 1:09:25 PM4/23/13
to ged...@googlegroups.com
You're welcome :) 

Miguel

Hayrettin Calboru

unread,
Jun 20, 2013, 5:09:32 PM6/20/13
to ged...@googlegroups.com
Hi All,

Where is this id is injected? I could not able to find in the source.

Anyone knows?

Regards,
Hayri

Matthew Eernisse

unread,
Jun 23, 2013, 3:14:43 PM6/23/13
to ged...@googlegroups.com
This happens at the DB adapter layer. In the "model" project (https://github.com/mde/model):

$ ack uuid lib
lib/adapters/base_adapter.js
31:    data.id = utils.string.uuid()

lib/adapters/memory/index.js
200:      var id = utils.string.uuid();

lib/adapters/mongo/index.js
290:        id = utils.string.uuid();

lib/adapters/riak/index.js
314:        id = utils.string.uuid();

lib/adapters/sql/base.js
135:      item.id = utils.string.uuid();
Reply all
Reply to author
Forward
0 new messages