Created
January 30, 2012 13:33
-
-
Save CmdrDats/1704412 to your computer and use it in GitHub Desktop.
Entities axample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defentity-template base-entity | |
(fields | |
[id :auto-index] | |
[version :version] | |
[uuid :uuid :indexed] | |
[dateadded :datetime]) | |
(post-create-fn server.entities.all/add-entity-triggers)) | |
(defentity group | |
(tablename "groups") ; Optional, but mysql doesn't respond well to 'group' as a table name, so better just avoid this altogether. | |
(extends base-entity) | |
(fields | |
[refid :bigint] | |
[name :full-varchar])) | |
(defentity address | |
(extends base-entity) | |
(fields | |
[street1 :text] | |
[street2 :text] | |
[suburb :text] | |
[city :text] | |
[code :varchar] | |
[type :enum ["Residential" "Postal"]])) | |
(defentity user | |
(tablename "users") ; Optional | |
(extends base-entity) | |
(fields | |
[refid :bigint] | |
[username :full-varchar] | |
[firstname :full-varchar] | |
[lastname :full-varchar] | |
[pwd :password] | |
[email :email] | |
[address :link address]) | |
(manytomany group) | |
(queries | |
:group "SELECT u.* FROM user_group ul, users u WHERE ul.group_id=:group-id AND u.id=ul.user_id" | |
:links "SELECT * FROM user_group WHERE user_id=:user-id")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment