mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
|
/**
|
||
|
* User.js
|
||
|
*
|
||
|
* @description :: A model definition represents a database table/collection.
|
||
|
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
|
||
|
*/
|
||
|
|
||
|
module.exports = {
|
||
|
attributes: {
|
||
|
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
|
||
|
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
|
||
|
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
|
||
|
|
||
|
email: {
|
||
|
type: 'string',
|
||
|
isEmail: true,
|
||
|
required: true
|
||
|
},
|
||
|
password: {
|
||
|
type: 'string',
|
||
|
required: true
|
||
|
},
|
||
|
isAdmin: {
|
||
|
type: 'boolean',
|
||
|
defaultsTo: false,
|
||
|
columnName: 'is_admin'
|
||
|
},
|
||
|
name: {
|
||
|
type: 'string',
|
||
|
required: true
|
||
|
},
|
||
|
avatar: {
|
||
|
type: 'string',
|
||
|
isNotEmptyString: true,
|
||
|
allowNull: true
|
||
|
},
|
||
|
deletedAt: {
|
||
|
type: 'ref',
|
||
|
columnName: 'deleted_at'
|
||
|
},
|
||
|
|
||
|
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
||
|
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
||
|
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
|
||
|
|
||
|
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
|
||
|
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
|
||
|
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
|
||
|
|
||
|
membershipProjects: {
|
||
|
collection: 'Project',
|
||
|
via: 'userId',
|
||
|
through: 'ProjectMembership'
|
||
|
},
|
||
|
subscriptionCards: {
|
||
|
collection: 'Card',
|
||
|
via: 'userId',
|
||
|
through: 'CardSubscription'
|
||
|
},
|
||
|
membershipCards: {
|
||
|
collection: 'Card',
|
||
|
via: 'userId',
|
||
|
through: 'CardMembership'
|
||
|
}
|
||
|
},
|
||
|
|
||
|
customToJSON: function() {
|
||
|
return {
|
||
|
..._.omit(this, 'password'),
|
||
|
avatar: this.avatar && `${sails.config.custom.uploadsUrl}/${this.avatar}`
|
||
|
};
|
||
|
}
|
||
|
};
|