Skip to content

Instantly share code, notes, and snippets.

@CmdrDats
Created January 30, 2012 13:33
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 CmdrDats/1704412 to your computer and use it in GitHub Desktop.
Save CmdrDats/1704412 to your computer and use it in GitHub Desktop.
Entities axample
(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