草庐IT

data_all

全部标签

mongodb - 将更新与 upsert 和 $all 一起使用

我无法让它工作:db.library.update({categories:{$all:['/movie/action','/movie/comedy'],$nin:['/movie/cartoon']},location:{$geoWithin:{$centerSphere:[[48.8574946,2.3476296000000048],50/6378.1]}}},{$setOnInsert:{categories:['/movie/action','/movie/comedy'],location:{type:'Point',coordinates:[48.8574946,2.3

java - 使用 spring-data-mongodb 将数组作为参数传递给过滤器函数

我有这个文件集:[{"name":"name1","data":[{"numbers":["1","2","3"]}]},{"name":"name2","data":[{"numbers":["2","5","3"]}]},{"name":"name3","data":[{"numbers":["1","5","2"]}]},{"name":"name4","data":[{"numbers":["1","4","3"]}]},{"name":"name5","data":[{"numbers":["1","2"]}]}]当作为参数传递的数组是data.numbers的子集时,我想获

java - 如何索引spring data mongodb中的所有字段?

假设我有一些名为candidates的集合。我想在此集合中的所有字段上创建一个text索引。在mongo中,我知道我可以这样做db.candidates.createIndex({"$**":"text"},{name:"TextIndex"})这是我的javapojo或实体。@Document(collection="candidates")publicclassCandidate{@IdprivateStringid;privateStringfirstName;privateStringlastName;//Otherstuff:removedforbrevity}现在如何在ja

mongodb - 具有多个字段的 Spring Data MongoDB 推送操作不起作用

我在MongoDB中有一组数据对象-[{"status":"passed","version":"124","value":6},{"status":"passed","version":"123","value":10},{"status":"failed","version":"123","value":16}]我想以这样的格式获取它-[{version:124,"series":[{"name":"passed","value":6}]},{version:123,"series":[{"name":"passed","value":10},{"name":"failed","v

node.js - 蒙戈/ express : How to return all documents in collection if no query params are passed?

如果没有传递查询参数,我将尝试从我的Mongo集合中返回所有文档。目前我有3个可选的查询参数可以由用户传递。localhost:3000/api/projects//shouldreturnallprojects.Currentlythisisreturning[]localhost:3000/api/projects?id=1//shouldreturnprojectswithidof"1".Workingproperly.localhost:3000/api/projects?name=myproject//shouldreturnprojectswithnameof"myproj

mongodb - Spring Data mongo 按 2 个字段值的差异进行过滤

我有如下文档Document{BigDecimaloriginalPriceBigDecimaldiscounPrice}现在我想得到结果,其中[originalPrice-discountPrice]的结果以分页方式从最大差异到最小差异。有没有一种方法可以使用springdatamongodb来实现这一点,而不必在第三个字段中保存差异而不是查询第三列?更新:根据@HbnKing的回答,我使用spring-data-mongodb尝试了以下操作,但现在出现错误ProjectionOperationprojectionOperation=project("originalPrice","

mongodb - 如何在 mongodb 的 spring-data 中映射枚举集合

带有MongoDB的Spring数据1.0.0.M3。spring怎么可以映射这个类:importorg.springframework.data.document.mongodb.index.IndexDirection;importorg.springframework.data.document.mongodb.mapping.Document;@DocumentpublicclassEnumsMapper{privateIndexDirectiond=IndexDirection.ASCENDING;}这个失败了:importorg.springframework.data.d

c# - 如何用mongoDB进行 "all or nothing"操作?

我需要在文档的字段数组中插入一些元素。好吧……我知道Mongo有原子更新。推送……事实是我需要在很多文档中做这个插入。情况如下(我需要为每个用户名插入一个角色数组):publicoverridevoidAddUsersToRoles(string[]usernames,string[]roleNames){foreach(stringroleinroleNames){if(!this.RoleExists(role)){thrownewProviderException(String.Format("Therole'{0}'wasnotfound.",role));}}//Howtog

mongodb - Spring Data MongoDB - 聚合框架 - 组操作中的无效引用

我使用SpringData(1.3.0.RC1)访问我们的MongoDB,对于一些新查询,我想使用聚合框架。在mongoshell中,命令是:db.spotreports.aggregate({"$unwind":"$pd"},{"$group":{"_id":"$pd.PDch","base":{$sum:"$pd.aBL"},"uplift":{$sum:"$pd.up"}}}){"result":[{"_id":5,"base":529133,"uplift":21516},...我使用的Spring代码是:Aggregationagg=Aggregation.newAggreg

java - Spring Data MongoDB 聚合转换?

我无法将以下mongodb聚合操作转换为SpringDataAggregationOperation。我正在使用SpringDataMongoDB1.3.2版本。db.ads.aggregate({$group:{_id:"$adId",req:{$sum:1},imp:{$sum:{$cond:[{$eq:["$imped",true]},1,0]}},click:{$sum:{$cond:[{$eq:["$clked",true]},1,0]}},bid:{$sum:{$cond:[{$eq:["$clked",true]},"$bid",0]}}}});我停在这里:Aggrega