简体   繁体   English

如何从名称为..的嵌入中删除文件,并且开始大于...?

[英]How to remove documents from embedded where name is.. and start is greater than…?

I'm trying to remove some embedded documents from history. 我正试图从历史中删除一些嵌入式文档。 I'm using mongodb 3.2 There are two conditions: 我正在使用mongodb 3.2有两个条件:

  1. "name" must be for example sa “名称”必须是例如sa
  2. "history" "start" must be greater some date “历史”“开始”必须更大一些日期
{
    "name" : "sa",
    "history" : [ 
        {
            "start" : ISODate("2015-11-11T12:46:32.000Z"),
            "value" : "color1"
        }, 
        {
            "start" : ISODate("2015-11-12T11:54:20.000Z"),
            "value" : "color2"
    }]
}
{
    "name" : "sa",
    "history" : [ 
        {
            "start" : ISODate("2015-11-11T12:46:32.000Z"),
            "value" : "color1"
        }, 
        ]
            "start" : ISODate("2015-11-12T11:54:20.000Z"),
            "value" : "color2"
    }] 
}
{
    "name" : "so",
    "history" : [ 
        {
            "start" : ISODate("2015-11-11T12:46:32.000Z"),
            "value" : "color1"
        }, 
        {
            "start" : ISODate("2015-11-12T11:54:20.000Z"),
            "value" : "color2"
    }] 
}

I couldn't do it directly. 我不能直接这样做。 I download the collection and then do the operations that I need, remove the old collection and then insert the new collection with the data that I need. 我下载了该集合,然后执行我需要的操作,删除旧集合,然后使用我需要的数据插入新集合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDB 如何计算子文档总数大于3且子文档值之和大于15000 - MongoDB How to count where total of sub documents is greater than 3 and sum of sub documents value is greater than 15000 如何获取KEY大于X的文档 - How to get documents where KEY is greater than X 如何从 MongoDb 中删除这些嵌入文档? - How to remove these embedded documents from MongoDb? 查询数组大小大于 1 的文档 - Query for documents where array size is greater than 1 如何查询日期大于提供日期的文档? - How can I query for documents where date is greater than a provided date? 如何返回数组字段大小大于给定数字的所有文档? - How to return all documents where an array field's size is greater than a given number? 使用pymongo,您如何找到所有文档,以便每个文档中的嵌入列表包含大于X个元素? - Using pymongo, how do you find all documents, such that an embedded list in each document contains greater than X elements? 如何查找field1大于field2的文档? (Nodejs /猫鼬/ MongoDB) - How to find documents where field1 is greater than field2? ( Nodejs/Mongoose/MongoDB) 查询数组中的字段大于x的文档 - Query for documents where field in array is greater than x 查询数组内数组大小大于 1 的文档 - Query for documents where array size inside array is greater than 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM