草庐IT

data-property

全部标签

node.js - Express.js+蒙戈: TypeError: Cannot read property then of undefined

我知道这里还有其他问题询问同样的错误,但我找不到适合我的情况的问题。我尝试连接mongo数据库:vardbConn=MongoClient.connect('mongodb://localhost',function(err,client){if(err)throwerr;vardb=client.db('mytestingdb');});我在这部分代码上遇到错误:app.post('/thanks',function(req,res){if(atendees.checkin===req.body.dbstring){dbConn.then(function(db){//errorhe

node.js - MongoDB 类型错误 : Cannot read property 'result' of undefined

我想向集合中插入数据,在插入之前我需要检查它是否存在collection.find({sno:req.body.sno}).toArray((err,result)=>{if(result.length>0){flag=false;callback(flag);}else{console.log(result.length);collection.insertOne({sno:req.body.sno,password:req.body.password},(err,insertResult)=>{if(insertResult.result.ok===1){flag=true;}ca

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 - 如何在 expressjs REST API 中修复 "TypeError: Cannot read property ' 正文“未定义””

我正在使用Express设置RESTAPI,我最终定义了一些有效的端点和方法,突然出现错误:“TypeError:无法读取未定义的属性‘body’”我是JS的新手,我正在尝试使用mongodb、express和react构建一个webapp。我一直在遵循一些指南(特别是这个指南,因为它也实现了JWT:https://www.toptal.com/nodejs/secure-rest-api-in-nodejs)我已经成功地为基本的CRUD操作构建了所有用户方法并公开了它们。一切正常,然后我尝试用中间件添加Auth进程,但出现了错误。我寻找答案,最常见的错误是由于在路由之后调用了body

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

mongodb - "missing : after property id"在简单 map/reduce 的上下文中意味着什么?

我在mongodb数据库中有一组对象,其中嵌入了测量值。我正在尝试进行映射/缩减以获取有关测量的统计信息。好吧,我遇到了一些问题,所以我只是让它尽可能简单:获取每个测量的数量。m=function(){emit(mp,{meas:this.measurements});};r=function(){return{count:meas.length};};res=db.meas_points.mapReduce(m,r,{query:{measurements:{$exists:true}}},{out:{"measurements_stats"}});当我运行此查询时出现错误:MonJ

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