2016-06-14 98 views
0

我想删除MongoDB中的空文档。 MongoDB的查询应该如何查看。我只想过滤不是每个字段都为空的文档。我只是想删除那些一个谁拥有所有领域的平等空删除MongoDB中的空文档

案例:

/* 1 */ 
{ 
    "_id" : ObjectId("57601e880855160fbb496f50"), 
    "instemail" : [], 
    "instProjekt1name" : [], 
    "inststrasse" : [], 
    "institutionID" : [], 
    "insttelefax" : [], 
    "insttelefon" : [], 
    "institutionsname" : [], 
    "instplz" : [], 
    "insturl" : [], 
    "instLand" : [] 
} 

/* 2 */ 
{ 
    "_id" : ObjectId("57601e880855160fbb496f51"), 
    "instemail" : [], 
    "instProjekt1name" : [], 
    "inststrasse" : [], 
    "institutionID" : [], 
    "insttelefax" : [], 
    "insttelefon" : [], 
    "institutionsname" : [], 
    "instplz" : [], 
    "insturl" : [], 
    "instLand" : [] 
} 

/* 3 */ 
{ 
    "_id" : ObjectId("57601e880855160fbb496f52"), 
    "instemail" : [ 
     "[email protected]" 
    ], 
    "instProjekt1name" : [ 
     "\n\t         ERA-Chemistry: Novel Pt-poor catalysts for the electrocatalytic O2 reduction based on modified, nanostructured metal oxides\n\t         ", 
     "\n\t         \"Welten\" von Mittelschichtangehörigen in zwei Satellitenstädten JABOTABEKs (Indonesien)\n\t         ", 
     "\n\t         Rätselspiele. Edition und Kommentar\n\t         ", 
     "\n\t         Analysis of the function of Presenilin in Development and Neurodegeneration in Drosophila melanogaster\n\t         ", 
     "\n\t         Estimating selection parameters and identifying loci under recent selection based on genome-wide sequence data\n\t         ", 
     "\n\t         Untersuchung polymerischer Stabilsation in kolloidalen Systemen unter Verwendung neuartiger feldtheoretischer Simulationen\n\t         ", 
     "\n\t         Entwicklung hämatopoietischer Stammzellen aus humanen ES- und iPS-Zellen\n\t         ", 
     "\n\t         Untersuchung polymerischer Stabilisation in kolloidalen Systemen unter Verwendung neuartiger feldtheoretischer Simulationen\n\t         " 
    ], 
    "inststrasse" : [ 
     "\r\n\t  \t   \t    Kennedyallee", 
     "40" 
    ], 
    "institutionID" : [ 
     "5000" 
    ], 
    "insttelefax" : [ 
     "+49 228 8852777" 
    ], 
    "insttelefon" : [ 
     "+49 228 8851" 
    ], 
    "institutionsname" : [ 
     "Deutsche Forschungsgemeinschaft" 
    ], 
    "instplz" : [ 
     "53175", 
     "Bonn" 
    ], 
    "insturl" : [ 
     "http://www.dfg.de" 
    ], 
    "instLand" : [ 
     "\r\n\t   \t   Deutschland\r\n\t  \t  " 
    ] 
} 

预计:

/* 3 */ 
{ 
    "_id" : ObjectId("57601e880855160fbb496f52"), 
    "instemail" : [ 
     "[email protected]" 
    ], 
    "instProjekt1name" : [ 
     "\n\t         ERA-Chemistry: Novel Pt-poor catalysts for the electrocatalytic O2 reduction based on modified, nanostructured metal oxides\n\t         ", 
     "\n\t         \"Welten\" von Mittelschichtangehörigen in zwei Satellitenstädten JABOTABEKs (Indonesien)\n\t         ", 
     "\n\t         Rätselspiele. Edition und Kommentar\n\t         ", 
     "\n\t         Analysis of the function of Presenilin in Development and Neurodegeneration in Drosophila melanogaster\n\t         ", 
     "\n\t         Estimating selection parameters and identifying loci under recent selection based on genome-wide sequence data\n\t         ", 
     "\n\t         Untersuchung polymerischer Stabilsation in kolloidalen Systemen unter Verwendung neuartiger feldtheoretischer Simulationen\n\t         ", 
     "\n\t         Entwicklung hämatopoietischer Stammzellen aus humanen ES- und iPS-Zellen\n\t         ", 
     "\n\t         Untersuchung polymerischer Stabilisation in kolloidalen Systemen unter Verwendung neuartiger feldtheoretischer Simulationen\n\t         " 
    ], 
    "inststrasse" : [ 
     "\r\n\t  \t   \t    Kennedyallee", 
     "40" 
    ], 
    "institutionID" : [ 
     "5000" 
    ], 
    "insttelefax" : [ 
     "+49 228 8852777" 
    ], 
    "insttelefon" : [ 
     "+49 228 8851" 
    ], 
    "institutionsname" : [ 
     "Deutsche Forschungsgemeinschaft" 
    ], 
    "instplz" : [ 
     "53175", 
     "Bonn" 
    ], 
    "insturl" : [ 
     "http://www.dfg.de" 
    ], 
    "instLand" : [ 
     "\r\n\t   \t   Deutschland\r\n\t  \t  " 
    ] 
} 

如何必须声明是什么样子?谁能帮我?

+0

IMO的帮助下,你可以找到它们的大小这些文件!但您需要知道文档类型的空白文档的大小。 [MongoDb中的文档大小](http://stackoverflow.com/questions/12657690/document-size-in-mongodb);)。 –

回答