Skip to content

Instantly share code, notes, and snippets.

@dogeared
Created January 9, 2013 19:02
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 dogeared/4495867 to your computer and use it in GitHub Desktop.
Save dogeared/4495867 to your computer and use it in GitHub Desktop.
"SELECT * FROM meetings WHERE meetingID = '1';"
"SELECT * FROM meetingAddress WHERE meetingID = '1';"
"SELECT * FROM districts WHERE districtID = '1';"
[
{
name: 'The Kensington Meeting',
timeZone: '',
districtID: 0,
url: 'http://',
meetingID: 1,
meetingType: '',
languageCode: '',
meetingAddress: {
countryCode: 'CA',
urbanization: '',
longitude: '',
phoneLabel: null,
name: '',
postcode: 'M5T 1J5',
password: '',
districtID: 0,
url: '',
locationNote: 'Currently held on 3rd/top floor -mPlease use the side door to enter and exit',
meetingID: 1,
city: 'Toronto',
state: 'ON',
phone: '',
username: '',
street1: '10 St. Andrew Street',
latitude: '',
street2: ''
},
description: '',
district: {
phoneLabel: null,
districtID: 1,
url: '',
phone: '',
districtNumber: 0,
email: '',
districtName: 'Independent'
}
}
]
global.inspect = require('eyes').inspector({maxLength: 10000000})
var FastLegSBase = require('FastLegS')
global.FastLegS = new FastLegSBase('mysql')
FastLegS.connect({host: 'localhost', port: 3306, database: 'd', user: 'u', password: 'p'})
var MeetingAddress = FastLegS.Base.extend({
tableName: 'meetingAddress',
primaryKey: 'meetingID'
})
var District = FastLegS.Base.extend({
tableName: 'districts',
primaryKey: 'districtID',
})
var Meeting = FastLegS.Base.extend({
tableName: 'meetings',
primaryKey: 'meetingID',
one: [
{ district: District, joinOn: 'meetingID' },
{ meetingAddress: MeetingAddress, joinOn: 'meetingID' }
]
})
Meeting.find(
1,
{ include: { meetingAddress: {}, district: {} } },
function(err, results) {
inspect(results)
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment