1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/models/User.js

99 lines
2.4 KiB
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
/**
* 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,
2019-08-31 04:07:25 +05:00
},
password: {
type: 'string',
required: true,
2019-08-31 04:07:25 +05:00
},
isAdmin: {
type: 'boolean',
defaultsTo: false,
columnName: 'is_admin',
2019-08-31 04:07:25 +05:00
},
name: {
type: 'string',
required: true,
2019-08-31 04:07:25 +05:00
},
2020-04-03 00:35:25 +05:00
username: {
type: 'string',
isNotEmptyString: true,
minLength: 3,
maxLength: 16,
regex: /^[a-zA-Z0-9]+(_?[a-zA-Z0-9])*$/,
allowNull: true,
},
2019-08-31 04:07:25 +05:00
avatar: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
2019-08-31 04:07:25 +05:00
},
phone: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
organization: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
defaultsTo: false,
columnName: 'subscribe_to_own_cards',
},
2019-08-31 04:07:25 +05:00
deletedAt: {
type: 'ref',
columnName: 'deleted_at',
2019-08-31 04:07:25 +05:00
},
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
membershipProjects: {
collection: 'Project',
via: 'userId',
through: 'ProjectMembership',
2019-08-31 04:07:25 +05:00
},
subscriptionCards: {
collection: 'Card',
via: 'userId',
through: 'CardSubscription',
2019-08-31 04:07:25 +05:00
},
membershipCards: {
collection: 'Card',
via: 'userId',
through: 'CardMembership',
},
2019-08-31 04:07:25 +05:00
},
tableName: 'user_account',
customToJSON() {
2019-08-31 04:07:25 +05:00
return {
..._.omit(this, 'password'),
avatar: this.avatar && `${sails.config.custom.uploadsUrl}/${this.avatar}`,
2019-08-31 04:07:25 +05:00
};
},
2019-08-31 04:07:25 +05:00
};