Created
June 14, 2014 17:33
-
-
Save clouddueling/70cee9b67077bd93b228 to your computer and use it in GitHub Desktop.
Through association with SailsJS. Make sure all references to models are lowercase because that is how they're stored.
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
module.exports = { | |
tableName: 'account_roles', | |
attributes: { | |
account_id: 'integer', | |
name: 'string', | |
description: 'text', | |
deleted: 'boolean', | |
users: { | |
collection: 'user', | |
via: 'accountRoles', | |
through: 'accountroleuser' | |
} | |
} | |
}; |
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
module.exports = { | |
tableName: 'account_role_user', | |
tables: ['users', 'account_roles'], | |
junctionTable: true, | |
attributes: { | |
id: { | |
primaryKey: true, | |
autoIncrement: true, | |
type: 'integer' | |
}, | |
users: { | |
columnName: 'user_id', | |
type: 'integer', | |
foreignKey: true, | |
references: 'user', | |
on: 'id', | |
via: 'accountroles', | |
groupBy: 'user' | |
}, | |
accountRoles: { | |
columnName: 'account_role_id', | |
type: 'integer', | |
foreignKey: true, | |
references: 'accountrole', | |
on: 'id', | |
via: 'users', | |
groupBy: 'accountrole' | |
} | |
} | |
}; |
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
module.exports = { | |
tableName: 'users', | |
attributes: { | |
name: 'string', | |
password: { | |
type: 'string', | |
minLength: 4, | |
required: true | |
}, | |
bio: 'string', | |
email: { | |
type: 'email', | |
required: true | |
}, | |
cloudinary_public_id: 'string', | |
accountRoles: { | |
collection: 'accountRole', | |
via: 'users', | |
through: 'accountroleuser' | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!! Following not works, in associated table, no records being added.