I have two models in sails
1. User_type
2. User
User_type Model:
module.exports = { schema: true, connection: 'mongo', attributes: { user_type: { type: 'string', required: true, enum: ['superadmin', 'admin', 'follower'] }, toJSON() { return this.toObject(); } }, beforeUpdate: (values, next) => next(), beforeCreate: (values, next) => next() };
User Model:
module.exports = { schema: true, attributes: { fname: { type: 'string', required: true, }, user_login_type: { // This user_login_type should be having values from // User_type Model with a reference to field 'user_type', that is // whatever values(superadmin', 'admin', 'follower') are in the // 'user_type' of collection(or model) 'User_type' should only be // allowed to enter here, and no else value }, toJSON() { return this.toObject(); } }, beforeUpdate: (values, next) => next(), beforeCreate: (values, next) => next() };
I referred to different docs, questions and answers, but am not getting the exact flow, how to do this in sails
Every help is really appreciable