const Schema = {}
Schema.UserProfile = new SimpleSchema ({
firstName :{
type:String,
label:'First Name',
optional:true,
max:50,
},
lastName:{
type:String,
label:'Last Name',
optional:true,
max:50,
}
});
Schema.MerchantProfile = new SimpleSchema ({
shopname:{
type :String,
label:"Shop Name"
}
});
const Users = Meteor.user()
Users.attachSchema(new SimpleSchema({
email:{
type:String,
regEx:SimpleSchema.RegEx.Email,
optional:true,
},
username:{
type:String,
optional:true,
},
services:{
type:Object,
optional:true,
blackBox:true
},
roles:{
type:String,
allowedValue:['admin','user','merchant']
},
heartBeat:{
type:Date,
optional:true
},
profile:{
type:Schema
autoValue:()=>{
if (Schema.roles =='user'){
return Schema.UserProfile;
}else{
return Schema.MerchantProfile
}
}
}
}))
Sorry it’s not possible. Fix the errors first.
am not seeing the error jus asking if you can use autoValue to do something like that.and if not possible how can i go about it .
My friend, you didn’t ask if you can use autoValue
to do something like that. You asked “is that possible” and pasted a long piece of code without any explanation on what you want to achieve, which made it very difficult to answer your post.
Now, when we know that you mean to use autoValue
to do something like that, here comes my advice to fix the errors first. Such as the aotuValue
instead of autoValue
, which will prevent this particular part of the code from even being called. That will be the first step in the right direction and will let you to actually test your function.
Then, you’ll probably have to replace Schema
inside of the function with a correct context. Because Schema.users
doesn’t provide an answer to “does user have a particular role” question.
should i replace it to Object or jus give me a snippet for that
please someone should help me out with this