草庐IT

Document_Conventions

全部标签

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

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

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 - 如何在 Mongoose 中使用 Document#update?

我在这里查看Mongoose中Document#update的示例:http://mongoosejs.com/docs/api.html#document_Document-update方法签名:Document#update(doc,options,callback)示例代码:weirdCar.update({$inc:{wheels:1}},{w:1},callback);文档说第一个参数应该是“doc”,但doc到底是什么?我想doc应该只是一个将键映射到要更新的新值的对象(默认情况下使用$set)。在代码示例中,他们试图将轮子增加1。然后在示例中,他们将{w:1}作为选项传递

mongodb - 失败 : error processing document in mongoimport

读取csv文件时出现以下错误:失败:错误处理文档#1:文字new或null中的无效字符“a”(应为“e”或“u”)有一些空白字段,我怀疑需要将其显示为“null”才能正确读取。我在这里正确吗?示例CSV:名称,年份,战斗编号,attacker_king,defender_king,attacker_1,attacker_2,attacker_3,attacker_4,defender_1,defender_2,defender_3,defender_4,attacker_outcome,battle_type,major_death,major_capture,attacker_siz

mongodb - 选择 'Partial Document'

在tutorial,有一个例子:SELECTjFROMthingsWHEREx=4返回的文档只给出了“j”个元素。如果我想返回所有文档的“j”元素怎么办(SELECTjFROMthings)? 最佳答案 提供一个空的过滤器/匹配表达式:db.things.find({},{j:true}) 关于mongodb-选择'PartialDocument',我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/qu

node.js - Mongoose .js : _id of embedded document

我正在尝试使用mongoose和MongoDB将任务保存到任务列表中。我想把它冗余地保存在任务集合和相应的列表文档中作为嵌入文档。它工作正常,但有一点:列表的嵌入文档没有它们的objectId。但我需要它们以便将它们与任务集合中的文档逻辑连接起来。我的模式:varTaskSchema=newSchema({_id:ObjectId,title:String,list:ObjectId});varTask=mongoose.model('task',TaskSchema);varListSchema=newSchema({_id:ObjectId,title:String,tasks:[