0
我对帆两种型号引用(外键)在sailsjs
1. User_type
2. User
USER_TYPE型号:
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() };
用户模型:
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() };
我提到不同的文档,问题和答案,但我没有得到确切的流动,如何在帆
每个帮助做到这一点实在是可观