search

Home  >  Q&A  >  body text

node.js - mongodb查找子对象的名称为某个值的对象的方法

如图,我建立了一个action表,想查找里面子对象joinObj的子对象id为1000的action对象。大概知道是使用type方法查询,具体应该怎么做呢?

ringa_leeringa_lee2873 days ago488

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 15:28:49

    I don’t quite understand whether 1000 refers to the sub-object called 1000, or userID=1000?
    If it is the former, there is no way to write it. If it’s the latter, there should be

    db.actions.find({"joinObj.1000.userID": 1000})
    

    Please clarify the issue before we can continue the discussion.

    reply
    0
  • Cancelreply