查询对象数组不包含属于字符串值的属性

时间:2015-09-09 00:12:19

标签: javascript node.js mongodb

鉴于以下文档,我如何查询.draggable { border: solid 2px gray; } .sidebar { position:fixed; width:200px; top: 51px; bottom: 0; left: 0; z-index: 1000; display: block; padding: 20px; overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ overflow-x: visible; background-color: #f5f5f5; white-space: nowrap; border-right: 1px solid #eee; padding-left: 30px; padding-right: 30px; } /* Sidebar navigation */ .nav-sidebar { margin-right: -21px; /* 20px padding + 1px border */ margin-bottom: 20px; margin-left: -20px; } .group{width:150px; height:auto;} #drophere{width:700px;left:200px; height:100vh;}不包含具有特定名称的对象的文档?

<link src="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<div class="common">
    <div class="container-fluid">
        <div class="row">
                <ul class="col-sm-3 col-md-2 sidebar nav nav-sidebar" > <li class="group" class="draggable" ><a href="#" class="list-group-item">
                <span class="badge">dasdsa</span>
                <span class="badge">dsad</span>
                <h4>
                 dsad
                 <br /><small>dsadsa</small>
                 <br /><small>dsadsa</small>
                </h4>
              </a>
                    </li>
                </ul>
             <div id="drophere" class="col-sm-9 col-md-9">MAIN PANEL</div>
        </div>
    </div>
   
</div>

我正在寻找与此相反的观点:

meta

我想查询相同的文档:

{ "_id" : 1, "meta" : [ { "name" : "alpha", "date" : ISODate("2015-09-08T19:51:03.275Z") } ] }

2 个答案:

答案 0 :(得分:3)

尝试

 db.content.find({'meta.name': {$ne: "beta"}})

因为$ne也适用于嵌套数组

答案 1 :(得分:0)

之前遇到过几个这样的问题。假设您的收藏品为&#39; test&#39;。试试这个

db.test.find({&#34; _id&#34;:1,&#34; meta&#34;:{$ elemMatch:{&#34; name&#34;:{$ ne:&# 34;测试&#34;}}}});