Skip to content

Instantly share code, notes, and snippets.

@devongovett
Created July 18, 2010 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save devongovett/480437 to your computer and use it in GitHub Desktop.
Save devongovett/480437 to your computer and use it in GitHub Desktop.
// #1. Standard hash, but with relationships defined outside of that hash
db.define('Employee', {
name: Record.type('String').required(),
employee_number: Record.type('Number').defaultValue(123)
})
Employee.hasOne('Office')
// #2. Put relationships in hash - user can name them anything they want.
db.define('Employee', {
office: Record.hasOne('Office')
name: Record.type('String').required(),
employee_number: Record.type('Number').defaultValue(123),
})
// #3. A (fab) like approach with relationships defined within the definition
with ( db )
define('Employee')
( hasOne, 'Office' )
( prop, 'name' ).type('String').required()
( prop, 'employee_number' ).type('Number').defaultValue(123)
();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment