草庐IT

mongo-shell

全部标签

javascript - Mongo 将 $slice 聚合到特定值而不是数组

我的收藏中有一个文档:{"_id":ObjectId("5b8aaaebf57de10e080c9151"),"user_email":"temp@temp.com","platforms_budget":[{"_id":ObjectId("5b8aaaebf57de10e080c9154"),"platform_id":"f_01","platform_name":"Facebook"},{"_id":ObjectId("5b8aaaebf57de10e080c9153"),"platform_id":"i_01","platform_name":"Instagram"},{"_id

c# - Mongo C# 驱动程序更新嵌套数组中的特定元素

如何在Mongo(C#驱动程序)中修改嵌套属性(数组)中的单个元素而不检索整个文档?publicclassElement{publicintValue{get;set;}publicstringName{get;set;}}publicclassDocument{publicElement[]Elements{get;set;}}在示例中,我想在单个查询中找到名称为“Car”的元素并将其值设置为4。 最佳答案 你需要$positionaloperator您可以在其中指定文档级条件和数组级条件以在特定文档的数组中查找单个嵌套项。在C#

python - 在 python 和 mongo 中使用多个 $regex 子句创建 $elemMatch 查询

我正在实现本教程HowtoSpeed-UpMongoDBRegexQueriesbyaFactorofup-to10我正在使用最后指定的查询db.movies.find({$and:[{$text:{$search:"MossCarrie-Anne"}},{cast:{$elemMatch:{$regex:/Moss/,$regex:/Carrie-Anne/}}}]});我遇到的问题是如何生成子查询$elemMatch:{$regex:/Moss/,$regex:/Carrie-Anne/}用python编程到目前为止我的代码defregexGen(s):d={}forwordins

node.js - Mongo 和 Node.js 查找和聚合

我正在使用Node.js和MongoDB,我需要同时使用“查找”和“聚合”功能。例如:varmongo=require('mongodb')mongo.MongoClient.connect(uri,{useNewUrlParser:true},function(errorConectDB,client){dbo.collection(this._objectName).find(query,options).aggregate(agr).toArray(function(err,res){....})})但是,当我执行我的代码时出现以下错误:TypeError:dbo.collect

mongodb - 比较mongodb中的日期

所以我收藏了这份文件db.person.insertOne({name:"vincent",age:40,alarm:{morning:newDate("2018-11-14T10:00:00Z"),night:newDate("2018-11-14T23:00:00Z")}})我需要检查下一个小时是否有闹钟(早上闹钟或夜间闹钟)这是我试过的db.person.find({"alarm.morning":{$lte:newDate(ISODate().getTime()+1000*60*60),$gte:newDate(ISODate().getTime()-1000*60*60)}}

javascript - node.js 中的 Mongo 在 $in 或类似的东西中添加一个 $gte/$lt

我使用MongoDBNode.js驱动程序。我的查询看起来像这样:varquery={$and:[{"custom_date":{"$gte":minDateValue,"$lt":maxDateValue}},{"doc_name":{"$in":file_type}},{"sample_type":{"$in":sample_type}},{"mission":{"$in":mission}},{"snow_thickness":{"$in":snow_thickness}},{"depth_m":{"$gte":minDepthOut,"$lt":maxDepthOut//Ore

show dbs 和 show databases 之间的 MongoDB shell 区别

根据MongoDbdocumentationMongoDBshell命令:showdbsPrintalistofalldatabasesontheserver.和showdatabasesPrintalistofallavailabledatabases.我很困惑-从我阅读和理解的内容来看,这些不是相同的效果命令-对吗?showdatabases不是showdbs的别名吗?showdbs列出的数据库可能不可用且未被showdatabases列出,对吗?如果是这样,数据库在服务器上但不可用怎么可能-用户的访问权限?showdatabases过滤背后的原因是什么?

java - 如何使用 Mongo Repository 查询同一个字段两次?

所以我想进行查询以查找我的集合中存在的所有任务,条件是在两个给定日期之间具有日期属性。我使用了Between关键字,但它不包括结果中的参数值。例如,如果参数为2019-09-20和2019-09-25,则不会在响应中返回为这些相同日期计划的任务。我尝试使用LessThanEqual和GreaterThanEqual,但出现以下错误:org.springframework.data.mongodb.InvalidMongoDbApiUsageException:Duetolimitationsofthecom.mongodb.BasicDocument,youcan'taddasecon

mongodb - 无法链接 mongo docker 容器

我有一张图像(gepick:latest),其中包含从Dockerfile创建的node应用程序:FROMcentos:7#CreateappdirectoryWORKDIR/usr/src/appRUNcurl--silent--locationhttps://rpm.nodesource.com/setup_8.x|bash-RUNyuminstall-ynodejsRUNcurl--silent--locationhttps://dl.yarnpkg.com/rpm/yarn.repo|tee/etc/yum.repos.d/yarn.repoRUNrpm--importhttp

mongodb - Mongo 查询 $exists :false not behaving as expected

{"_id":ObjectId("5c541529fc3e371af7720346"),"name":"Sanjeev","hobbies":[{"title":"Trekking","frequency":3},{"title":"Cooking","frequency":4}],"phone":122311223}{"_id":ObjectId("5c541529fc3e371af7720347"),"name":"siddhanth","hobbies":[{"title":"Trekking","frequency":3},{"title":"Cooking","frequen