草庐IT

document-conversion

全部标签

javascript - Mongoose : update nested document array

我的收藏如下:"_id":ObjectId("5751f7892ae95d601f40411d"),"doc":[{"org":ObjectId("5751f7892ae95d601f40411c"),"action":0,"_id":ObjectId("5751f7892ae95d601f40411e")},{"org":ObjectId("5751952cace204c507fad255"),"action":1,"_id":ObjectId("575217ce341cf6512b8dff39")}]我想用org:5751952cace204c507fad255更新文档中的操作字段

node.js - 蒙哥错误: can't convert from BSON type missing to Date while Grouping records in nested documents

基本上我想根据月份对民意调查进行分组。我的模型:varmongoose=require('mongoose');varSchema=mongoose.Schema;varvoteSchema=newSchema({ip:String,votedOn:{type:Date,default:Date.now}});varchoiceSchema=newSchema({text:String,votes:[voteSchema]});varPollSchema=newSchema({question:{type:String,required:true},choices:[choiceSch

node.js - 为什么在我的 .find() 输出中添加了 "Document"这个词?

发布命令Collection.find({})在一个meteor后端输出中的输出:[Document{_id:'fpYe5XepB9AfJM4PJ',}]...而另一个命令中的相同命令会输出文档[{_id:'fpYe5XepB9AfJM4PJ',}]包含的“Document”元素是什么意思,两者的功能区别? 最佳答案 这意味着数组的第一个元素是Document构造函数的一个实例。某些日志记录实用程序(如Chrome控制台的记录器)会显示对象的类型以提供更多信息。下面是构造函数的一个简单示例:>varDocument=function

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

ruby-on-rails - 在 MongoDB 中存储数据的有效方法 : embedded documents vs individual documents

我存储用户事件数据:当用户访问当前文章、主题或个人消息时,以显示他在离线时添加了多少新评论和消息。classSiteActivityincludeMongoid::DocumentincludeMongoid::Timestampsbelongs_to:userbelons_to:activity,polymorphic:trueend在这种情况下,我为每个文档存储一条记录。另一种选择是使用嵌入式文档,因此所有用户事件都将存储在一个文档中:classSiteActivityincludeMongoid::Documentbelongs_to:userembeds_many:user_a

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:""}});}代码非

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

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

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