<div dir="ltr">Hi Ross,<div><br></div><div>The primary key if it is generated by a database is not part of the entity. However, you can store it in your entity if you supply it yourself. It is a good approach if your entity has a natural primary key (like username). Only default key can be auto-incremented. Here is more detailed description of how keys work in Groundhog https://www.fpcomplete.com/user/lykahb/groundhog#keys-and-references </div><div><br></div><div>Also you may want to use project instead of select. For example, "project (AutoKeyField, MyConstructor) $ MyField ==. myValue" would return id and the entity. <br><br>Thank you,</div><div>Boris Lykah<br><br><br>On Sunday, March 30, 2014 12:41:40 AM UTC-4, Ross Pokorny wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr">Hello,<div><br></div><div>I am trying to build a RESTful web application using Groundhog for persistence.  In order to generate URLs for my entities (e.g. for the Location HTTP header), I need a way, given that I have an entity, to obtain its id (its AutoKey).  From what I've gathered so far, in normal Groundhog usage, the primary key is not part of the actual entity datatype.  The only place where I've seen it returned is from the 'insert' functions in Database.Groundhog.  I need the id in cases where I have retrieved an already-existing entity using 'select', but I cannot find a way to obtain it.<br><br>I gather that this might not be possible with the current API, and that instead, I may need to explicitly define a field on the entity type to store the id instead of using the auto-generated field that Groundhog normally provides.  In that case, my question is how do I set up that field to be an auto-incrementing key, and not simply a value with a unique constraint.  Also, would Groundhog recognize that field as the AutoKey, and would it return it from 'insert' calls?</div><div><br></div><div>Thanks,</div><div><br></div><div>Ross Pokorny</div></div></blockquote></div></div>