草庐IT

mongodb-csharp

全部标签

c# - 对象的MongoDB反序列化/反序列化

我有以下类(class)。publicclassUser:System.Security.Principal.IPrincipal{publicint_id{get;set;}publicIIdentityIdentity{get;set;}publicboolIsInRole(stringrole){}}我正在尝试使用以下代码将此类的实例保存到MongoDB:newMongoClient("").GetServer().GetDatabase("").GetCollection("").Save(newUser{_id=101,Identity=newGenericIdentity(

MongoDB,mongorestore : "Can only replay oplog on full restore"

我在恢复转储和重播MongoDB上的操作日志时遇到了一些问题。我必须重播oplog到某个时间点,因此发出以下命令:mongorestore--port--db--oplogReplay--oplogLimit但是mongorestore回复“Canonlyreplayoplogonfullrestore”。Lookingatthesourcecode当用户未指定--db选项时似乎会显示此错误消息,但我指定了。您知道还有什么原因吗? 最佳答案 我认为这是相反的问题-使用oplog选项时不能指定数据库。您找到的代码:if(mongoRe

mongodb - 最新的 meteor mongo shell?

当我运行meteormongo时,我得到:MongoDB外壳版本:2.4.9但我刚刚升级到最新的mongo(2.6.1)如何在安装了最新的mongoshell版本(2.6.1)的情况下运行meteormongo? 最佳答案 Meteor有自己的一组依赖项,包括MongoDB。这意味着Meteor使用的版本取决于Meteor本身而不是您的系统。请参阅thisfile中的“更新的依赖项”注释了解更多详情。 关于mongodb-最新的meteormongoshell?,我们在StackOver

Mongodb 地理位置边界搜索/查询

我有一个包含位置“框”(正方形区域)列表的文档。每个框由2个点表示(左下角或西南角、右上角或东北角)。文档,例如:{locations:[[[bottom,left],[top,right]],[[bottom,left],[top,right]],[[bottom,left],[top,right]]]}我正在使用2d这些边界点的索引。我的输入是一个特定的位置点[x,y],我想获取列表中包含该点所在的所有文档。有没有geospatialoperator我可以用它来做吗?如何编写此查询? 最佳答案 您可以使用框运算符,请参阅:htt

mongodb - 为什么覆盖查询在 MongoDB 中有时会变慢?

我的印象是覆盖查询总是比扫描集合本身更快。那么为什么这个覆盖查询变慢了呢?覆盖查询:>db.group_panel_responses.find({},{_id:0,_panel_id:1,_group_id:1,response_count:1}).hint({_panel_id:1,_group_id:1,response_count:-1}).explain(){"cursor":"BtreeCursor_panel_id_1__group_id_1_response_count_-1","isMultiKey":false,"n":20000,"nscannedObjects"

mongodb - 如何调试我的 mongodb 索引?

我的搜索在生产环境中花费了80多秒,但在我的本地环境中只需要一秒钟(数据几乎相同)。我不确定接下来可以采取什么步骤。查询看起来像:@params={search_field:'kamil'}User.only('username','email','name','role','utm_email').or({:"email"=>/#{@params[:search_field]}/i},{:"username"=>/#{@params[:search_field]}/i},{:"name"=>/#{@params[:search_field]}/i}).explain()explain

mongodb - 使用复选框过滤集合

假设我有一个名为Cars的集合,拿着大量文件。假设我有5,每个对应于color键入Cars文档。我想根据选中的复选框使用选择器查询集合。这个问题的最佳解决方案是什么?现在看来我要写很多if声明。有没有更好的办法?谢谢 最佳答案 您可以将选定(选中)的颜色集存储在Session变量中,并在返回Cars的帮助程序中使用该Session变量的值。下面给出一个完整的解决方案。将这两个文件另存为cars.html和cars.js。{{>filter}}{{>carList}}{{#eachcolors}}{{.}}{{/each}}{{#ea

自从 2.4 升级到 2.6 后,MongoDB 索引查询返回不正确的值

自从从2.4升级到2.6后,我发现索引导致一些查询产生不正确的值。我们的数据集是这样的://Thisisasimplifiedharnesstoreplicatewhatwe'reseeinginourDB/**number_user_idindexes**/db.getCollection("number_user_id").ensureIndex({"_id":NumberInt(1)},[]);/**number_user_idindexes**/db.getCollection("number_user_id").ensureIndex({"user_id":NumberLon

mongodb - 为 meteor 构建一个动态的 mongo 查询

我正在构建一个具有可点击“过滤器”的应用程序;我正在创建一个对象列表(?),我想将其传递给mongo“查找”,这样我就可以在所选属性与特定分数匹配时提取列表。我的数据结构如下(片段):name:'EntryOne',location:{type:'Point',coordinates:[-5.654182,50.045414]},dogs:{score:'1',when:'seasonal',desc:'DogsallowedfromOctobertoApril'},lifeguard:{score:'1',when:'seasonal',desc:'Alifeguardhutisma

mongodb - Mongoose query.populate 只返回 objectId

当尝试填充一个字段时,所有返回的都是最初为该字段保存的objectid在models/gifts.jsvarGiftSchema=newSchema({name:String,owner:{user:{type:Schema.Types.ObjectId,ref:'User',required:false},nonRegisteredEmail:{type:String,required:false},nonRegisteredName:{type:String,required:false}},description:String,url:String}});module.expor