草庐IT

END_DOCUMENT

全部标签

Java + MongoDB : Updating fields in amount of document

我正在尝试立即更新文档数量中的字段,我想修改"download=0"其中"md5"在列表中。当我运行代码时,它抛出异常:java.lang.IndexOutOfBoundsException:Index:0,Size:0atjava.util.ArrayList.rangeCheck(UnknownSource)这就是我正在做的://thelistisanlistof"md5"ListupdateCondition=newArrayList(list.size());for(inti=0;i异常发生在:updateCondition.get(i).put("md5",list.get(

mongodb - Mongo-Scala-Driver:CodecConfigurationException:找不到类 immutable.Document 的编解码器

错误信息:org.bson.codecs.configuration.CodecConfigurationException:Can'tfindacodecforclassorg.mongodb.scala.bson.collection.immutable.Document代码:defqueueWrite(collection:String,filter:Map[String,()=>String],data:Map[String,()=>String]){valcol=collections.get(collection).getvalfilterBson=Document()fi

java - MongoDB Java 驱动程序 : Convert BsonDocument to Document and back

我正在为我的项目使用MongoDBJava驱动程序以从Java访问我的数据库。我通常使用Document因为它非常易于使用,所有方法都在MongoDBCollection中,例如find()使用它并返回Document实例。但是,在某些情况下我想使用等效的BsonDocument这更冗长,但通过实现Map提供类型安全,这Document没有,因为它实现了Map.我能够转换Document进入BsonDocument有了这个:BsonDocumentbsonDoc=document.toBsonDocument(BsonDocument.class,MongoClient.getDefa

mongodb - phalcon 0.6.0 ODM (object-document mapper) for MongoDB 我该如何使用?

公告中0.6.0includesbasicODM(object-documentmapper)forMongoDB谁能提供更多信息? 最佳答案 Phalcon0.6.0将提供一个ODM以面向对象的方式操作Mongo文档。这不是最终的用法,但它会给你一个想法:set('mongo',function(){$mongo=newMongo("mongodb://localhost");return$mongo->selectDB('invo');});//Registeracollectionmanager$di->set('collec

C++ vector find()使用? ( if!=vec.end())

std::vector::find是C++STL中的一个函数,它可以用来在std::vector中查找给定的元素。如果找到了这个元素,它将返回一个迭代器指向该元素,否则将返回一个名为end()的迭代器。下面是一个使用find的示例代码:#include#include#includeintmain(){std::vectorv={1,2,3,4,5};//查找数字3autoit=std::find(v.begin(),v.end(),3);if(it!=v.end()){std::cout输出:Found3atposition2find函数有两个参数:begin:一个迭代器,指向查找范围的开始

mongodb - MongoCursor<Document> 与 FindIterable<Document> 之间的区别

我想知道MongoCursor和FindIterable之间的区别。MongoCursor:MongoCursorcursorPersonDoc=personDocCollection.find(whereClauseCondition).iterator();while(cursorPersonDoc.hasNext()){Documentdoc=cursorPersonDoc.next();Strings1=doc.getString("s1");}FindIterable:FindIterablecursorPersonDoc=personDocCollection.find(w

java - 获取 com.mongodb.MongoSocketReadException : Prematurely reached end of stream- MongoDB

我正在尝试将我的Java应用程序连接到MongoDB服务器。我正在使用Java8,mongodb服务器4.0.9,mongo-java-驱动程序:3.10.0我能够连接到我的本地主机服务器,但是在连接到通过自签名启用ssl的远程服务器时出现以下错误。INFO:Clustercreatedwithsettings{hosts=[host-name:27017],mode=SINGLE,requiredClusterType=UNKNOWN,serverSelectionTimeout='300000ms',maxWaitQueueSize=500}Jun07,20193:33:36PMc

php - mongodb 'document'变量在PHP中定义

我正在使用Codeigniter和PHP。我们可以为mongodb查询定义空数组,如下所示,$db->user->insert(array('report'=>array()));我如何在PHP中为mongodb定义空的document(数据类型)?我知道,我可以在使用另一个运行时查询(使用$set或其他)时创建document变量。但是当我insert时,我需要创建document变量。如果我像下面这样创建文档变量,$a=array();$db->user->insert(array('report'=>$a));以下代码无效,$db->user->update(array('use

node.js - Mongoose ,MongoDB : How to save() document after push()?

架构:varPost=mongoose.Schema({title:String,comments:[{user:Number,text:String}]});代码:oldCount=myPost.comments.length;//forexample'n'myPost.comments.push({user:42,text:'blablabla'});newCount=myPost.comments.length;//shouldbe'n+1'myPost.save(function(err){...});它是一个合适的代码吗?save()是否会在push()之后执行?我会得到正确

mongodb - "errmsg": "exception: $unwind: value at end of field path must be an array"

查询:db.trace.aggregate([{$unwind:"$likes"},{$group:{_id:{"name":"$name"}}}]);Mongo集合:"likes":[{"category":"test1","name":"test1","created_time":"2014-01-08T20:50:02+0000","id":"14157481053234234"},{"category":"Publisher","name":"CityPulse","created_time":"2014-01-06T22:46:19+0000","id":"169217625