0

I have a collection named Apprentices looks like this:

{
"_id": "BCKnMu5ixBFJys6G9",
"skills": {
    "apGit": true,
    "apCPlus": false,
    "apCSharp": false,
    "apC": false,
    "apJava": false,
    "apJavaScript": false,
    "apMetor": false,
    "apSQL": false,
    "apMongoDB": false,
    "apPHP": false,
    "apPython": false,
    "apHTML": false,
    "apJQuery": false,
    "apiOS": false,
    "apAndroid": false,
    "apRuby": false,
    "apRubyOnRails": false,
    "apNet": false,
    "apSVN": false,
    "apAPI": false,
    "apDevOps": false,
    "apCLI": false,
    "apVM": false,
    "apLinux": false,
    "apOther": false
},
"userID": "8bTuAAZYbu7Xb3ssX"
}

and I want to get the specific value of the skills.

With: let user = Apprentices.findOne({'userID' : Meteor.userId()});

I can get user.skills.apGit is true.

But if I want to use a variable like

let n = 'apGit'

user.skills.n will be error.

My question is How can I get the value of the apGit by using n???

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
Gang Fan
  • 15
  • 5

0 Answers0