I was able to get the User
document with this code
Users.findOne(userId)
also Users
looks like this.
{
"_id" : "123sdasdasd",
"createdAt" : ISODate("2022-06-15T20:36:01.549+0000"),
"archived" : false,
"roles" : {
"internal" : [
"admin",
"maneger"
],
"client" : [
"admin",
"maneger",
"normal-user",
],
"other" : [
"admin",
"maneger",
"normal-user",
"manage"
],
},
"username" : "sample@gmail.com"
}
My goal here is to make sure if this user has a roles
column with client
.
I believe this is on the server side but part of my code looks like this.
Roles.removeUsers = (userId, groupName) => {
console.log(Users.findOne(userId)); // got document successfully
console.log(Users.findOne(userId).roles[groupName]); // got undefined
if (Users.findOne(userId).roles[groupName].length < 1) {
sampledataUpdate.$pull.userIds = userId;
}
};
The groupName
could be internal
, client
, other
or other strings.
Currently, I’m getting groupName
as client
.
How can I make sure if this user has client
in roles
column?
also another little question is if you look at the data structure above,
can I say roles
as column
?
_id
, createdAt
, archived
are column
?
and inside of column(roles for this case), what is the right word to describe internal
, client
or other
? Would that be key
?
Thank you!