MongoDB Query Update

1,Query


$elemMatch用法:
{"contents":{$elemMatch:{"fieldId":"project_type","content":"民间文学"}}}
$and的用法:
{ "$and" : [{"contents":{$elemMatch:{"fieldId":"project_type","content":"民间文学"}}},{"contents":{$elemMatch:{"fieldId":"batch","content":"2"}}}]}
$or的用法:
{ "$or" : [{"contents":{$elemMatch:{"fieldId":"project_type","content":"民间文学"}}},{"contents":{$elemMatch:{"fieldId":"batch","content":"2"}}}]}

 

explain用法:

  explain()是非常有用的工具,会帮助你获得查询方面诸多有用的信息。只要对游标调用该方法,就可以得到查询细节

  eg:db.role.find().explain()
2,Update

 

 

你可能感兴趣的:(mongodb,query)