Skip to content
Snippets Groups Projects
Commit 0f505beb authored by Louis's avatar Louis :fire:
Browse files

Default user age bracket to 'youth'

parent 82ac76cb
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ module.exports = (sequelize, DataTypes) => { ...@@ -36,7 +36,7 @@ module.exports = (sequelize, DataTypes) => {
Model.prototype.toJSON = function userToJSON() { Model.prototype.toJSON = function userToJSON() {
const age = this.hasOwnProperty('age') ? { age: this.age } : { } const age = this.hasOwnProperty('age') ? { age: this.age } : { }
const meta = this.meta const meta = { ...this.meta }
if (meta.hasOwnProperty('dob')) { if (meta.hasOwnProperty('dob')) {
delete meta.dob delete meta.dob
} }
...@@ -114,7 +114,7 @@ module.exports = (sequelize, DataTypes) => { ...@@ -114,7 +114,7 @@ module.exports = (sequelize, DataTypes) => {
replacements: { userId: this.id }, replacements: { userId: this.id },
type: sequelize.QueryTypes.SELECT, type: sequelize.QueryTypes.SELECT,
}).catch(e => console.error(e) || [null]) }).catch(e => console.error(e) || [null])
return (userAge && userAge.age) ? (userAge.age.years < 18 ? 'youth' : 'adult') : 'adult' return (userAge && userAge.age) ? (userAge.age.years < 18 ? 'youth' : 'adult') : 'youth'
} }
Model.associate = function defineModelAssociations(models) { Model.associate = function defineModelAssociations(models) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment