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() };
我提到不同的文檔,問題和答案,但我沒有得到確切的流動,如何在帆
每個幫助做到這一點實在是可觀