Skip to content

Instantly share code, notes, and snippets.

@mschwartz
Created September 1, 2013 15:31
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 mschwartz/6405170 to your computer and use it in GitHub Desktop.
Save mschwartz/6405170 to your computer and use it in GitHub Desktop.
Schema.add({
name: 'Content',
fields: [
{ name: 'contentId', type: 'int', autoIncrement: true, defaultValue: 0 },
{ name: 'seoFriendly', type: 'varchar', size: 255 },
{ name: 'title', type: 'varchar', size: 255, defaultValue: 'Untitled' },
{ name: 'description', type: 'varchar', size: 255, defaultValue: 'No description' },
{ name: 'body', type: 'longtext' }
],
primaryKey: 'contentId',
indexes: [
'seoFriendly'
]
});
Schema.add({
name: 'Churches',
fields: [
{ name: 'churchId', type: 'int', autoIncrement: true, defaultValue: 0 },
{ name: 'churchName', type: 'varchar', size: 255, defaultValue: 'Unknown' },
],
primaryKey: 'churchId'
});
Schema.add({
name: 'ChurchContentRelationships',
fields: [
{ name: 'churchId', type: 'int' },
{ name: 'contentId', type: 'int' }
],
primaryKey: 'churchId, contentId'
});
// get all content related to a specific church
SQL.getDataRows([
'SELECT',
' *',
'FROM',
' Content,ChurchContentRelationships',
'WHERE',
' ChurchContentRelationships.churchId = ' req.session.churchId,
' AND Content.contentId=ChurchContentRelationships.contentId'
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment