草庐IT

indexed_document

全部标签

javascript - Mongo 外壳光标 : updated documents get to cursor again

我正在尝试在Mongoshell中遍历游标以更新集合中的所有文档。我的目标是重命名文档中的一些字段,所以代码看起来像这样:varcursor=db.collection.find();while(cursor.hasNext()){vardoc=cursor.next();printjson(doc);db.collection.update({_id:doc._id},{$set:{docId:doc.docID,createdAt:doc.dateAdded,updatedAt:doc.dateAdded},$unset:{dateAdded:"",docID:""}});}代码非

python - PyMongo 抛出 "E11000 duplicate key error index"

期望将重复文档插入到mongodb集合中,因此使用unique=True和dropDups=True创建了一个索引。db.myCollection.create_index("timestamp",unique=True,dropDups=True)但是,如果同一组文档被插入两次,第一次插入没问题,但第二次插入会抛出错误db.myCollection.insert(json.loads(df.to_json()).values())DuplicateKeyError:E11000重复键错误索引:myDb.myCollection.$timestamp_1dupkey:{:1385290

mongodb - 学说 ODM : Embedding multiple GridFS documents exception

我正在尝试通过Doctrine/Symfony2在GridFS的主要大图像中嵌入缩略图。主要图片文件如下,id;}publicfunctionsetId($id){$this->id=$id;}publicfunctiongetTags(){return$this->tags;}publicfunctionsetTags($tags){$this->tags=$tags;}publicfunctiongetFile(){return$this->file;}publicfunctionsetFile($file){$this->file=$file;}publicfunctionget

ruby - 使用 GridFS 时出现 "Document exceeds allowed max BSON size. The max is 16777216."错误

我正在尝试使用GridFS和ruby​​在我的mongo数据库中插入一个33MB的视频文件,并且我有一个系统的“文档超出允许的最大BSON大小。最大值为16777216。”。我认为在mongo集合中插入大于16MB的文件的唯一方法是使用Gridfs,所以我怀疑我做错了,即使我复制/粘贴了Ruby驱动程序示例(http://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial/#gridfs)。我正在使用Ruby2.2.1、mongo驱动程序2.0.4和mongodb3.0.1。我的代码:eDatabase=Mongo::Cli

node.js - 添加大写 : true to mongoose embedded document

如果我有两个模式,一个将嵌入另一个:varmongoose=require("mongoose");varSchema=mongoose.Schema;//WillembedthisinthepersonSchemabelowvaraddressSchema=newSchema({street:String,city:String,state:{type:String,uppercase:true},zip:Number});varpersonSchema=newSchema({firstName:{type:String,required:true},lastName:{type:S

MongoDB : text index with arrays, 只有第一项被编入索引

我有一个具有以下架构的文档{description:String,tags:[String]}我已将这两个字段编入索引,但问题是每当我搜索数组中的特定字符串,只有当该字符串是数组的第一个元素时,它才会返回文档。因此,$text索引似乎只适用于第一个元素,这是mongo固有的工作方式还是必须传递给索引的选项?示例文档{description:'randomdescription',tags:["hello","there"]}创建索引的对象{description:'text',tags:'text'}查询db.myCollection.find({$text:{$search:'hel

java - Mongo Java 驱动程序 3 - 使用扩展 'Document' 的对象

MongoJava驱动程序3添加了对Codecinfrastructure的支持,我正在下面尝试。默认情况下,它带有以下3个对象的编解码器:Document、BasicDBObject和BsonDocument。我试图通过让我的类MyClass扩展Document来做一些非常简单的事情。但是,它失败并显示内联指示的错误。我找到了这个gist但它似乎过于复杂..是否没有一种简单的方法可以将MyClass注册为编解码器,因为它也是一个文档?谢谢。-亨宁publicclassPlayMongo{staticclassMyClassextendsDocument{publicMyClass(S

mongodb - mongodb 中的 system.indexes 用于备份

我正在使用mongodump工具收集备份,在此期间我使用excludeCollection选项排除了一些我不需要的收集。作为mongodump的一部分,我们有一个系统集合system.indexes,如果我从备份中排除这个集合,在恢复过程中会有什么影响吗? 最佳答案 根据文档。mongodumponlycapturesthedocumentsinthedatabaseinitsbackupdataanddoesnotincludeindexdata.还有……mongorestorerecreatesindexesrecordedby

javascript - 蒙哥错误: No More Documents in Tailed Cursor

我有一个上限集合,我正尝试使用mongoose对其进行尾部处理。当所有文档都用完或根本没有文档时,tailable流会出错。Mongoose模式varphotoSchema=newSchema({name:String,operations:Schema.Types.Mixed,},{capped:{size:300*500,max:500,autoIndexId:true}});实现varRawPhoto=mongoose.model('RawPhoto',photoSchema);varProcessedPhoto=mongoose.model('ProcessedPhoto',p

Node.js MongoDB 创建多个索引 : no index name specified

我正在使用MongoDB版本2.6.11如何解决这个错误?在Node.jsAPIreference您可以传递的唯一参数是一个索引规范数组和一个回调函数,我应该在哪里指定索引名称?我正在使用的代码如下(假设我已经需要mongoclient并已连接到数据库):db.collection("MyCollection").createIndexes([{field1:1},{field2:1,field3:1}],function(err,result){//Errorhandlingcode});错误代码为67,错误的完整堆栈跟踪如下:MongoError:noindexnamespecif