草庐IT

self-updating

全部标签

c# - MongoDB c# Update.PushWrapped,怎么用?

我如何将一个项目推送到数组中?我发现我只能插入基本值(String、Int32、Int64、Boolean),但我不能将自定义类的实例插入到数组中。//inthisway,itwork:varmyPlayer=newi_Player();this.mongo_collection.FindAndModify(Query.EQ("_id",ID),SortBy.Ascending("_id"),Update.PushWrapped("_player",myPlayer),true);//inthisway,don'tworkbecausei_PlayerisnotanBsonValueb

python - Flask-PyMongo : how come "self._Collection__database"?

在Flask-PyMongo中,他们使用self._Collection__database来表示这个Collection对象所属的数据库对象:classCollection(collection.Collection):"""Customsub-classof:class:`pymongo.collection.Collection`whichaddsFlask-specifichelpermethods."""def__getattr__(self,name):attr=super(Collection,self).__getattr__(name)ifisinstance(att

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

angularjs - MongoDB + AngularJS : _id empty in update via resourceProvider

我正在使用Mongodb(Rails3+Mongoid)和AngularJS。在我的数据库中,我有一个集合users,它包含一组对象addresses。我正在尝试更新数组中某个地址的字段,但是当我发送更新请求(使用Angular的resourceProvider)时,Angular发送到我的服务器的所有_id是“{}”(即空),所以我最终得到了复制而不是修改。$scope.user.addresses包含非空ID,看起来像这样:[{_id:{$oid:"123431413243"},text:"123fake",cat:1},{_id:{$oid:"789789078907890},t

mongodb - NoSql self 加入喜欢

我想了解我是否可以以任何方式使用NoSql执行以下操作。我将以航类为例。假设我有包含以下信息的航类表或集合:...{from:XXX,to:YYY,date:01-01-2016}{from:YYY,to:XXX,date:02-02-2016}...我需要能够执行诸如自连接之类的操作来找到完整的路线:{from:XXX,to:YYY,outbound:01-01-2016,inbound:02-02-2016}表格应该有很多from和to位置。是否可以在没有关系数据库的情况下做到这一点? 最佳答案 Isitpossibletodo

javascript - Mongodb update() 与 findAndModify() 性能对比

对于不断增长的文档,我可以选择使用update()或findAndModify()来插入新的数组字段中的元素。但是,findAndModify()将在我的特定应用程序中生成更清晰的代码。但是我可以使用update()实现相同的功能,只是更加困惑。我只是想知道使用update()而不是findAndModify()能获得多少性能提升。非常感谢! 最佳答案 我使用mongoshell进行了快速测试。对于本文档:{"c":50,"growingArray":[0]}我运行了两个测试:for(i=1;i在我的中端笔记本电脑上总共花费了40.

node.js - Mongoose - 聚合添加 'is_self' 字段

我正在构建一个聊天应用程序,它应该从MongoDB检索所有新消息,并分组到对话中。但是每条消息都应该有一个新的“is_self”字段编辑:“is_self”字段包含一个bool值,表示消息是否来自用户。如此伪:is_self:{$cond:{if:{message.sender==MYID)},then:true,else:false}假设我有消息模型varMessageSchema=newSchema({conversation_id:{type:mongoose.Schema.ObjectId,ref:'Conversation',required:true},message:{t

django - Mongoengine 原始 find_and_modify 查询给出 "Must either update or remove"异常

我正在使用Django+mongoengine我想更新我的Bookscollection文档中的书籍(嵌入式文档)计数。我希望更新查询返回完整的对象。因此我正在使用“find_and_modify”。但即使我使用更新或删除字段。我仍然收到“必须更新或删除”的错误消息。这是我的代码片段-forbook_idinbook_list:book_col=BookCollection._get_collection().find_and_modify({'query':{'coll_id':book_coll_id,'book.book_id':book_id},'update':{'$inc'

ruby - MongoDB + ruby : updating records in an iteration

使用MongoDB和Ruby驱动程序,我试图在我的应用程序中计算玩家的排名,因此我按(在本例中)俯卧撑排序,然后添加一个排名字段和每个对象的值。pushups=coll.find.sort(["pushups",-1])pushups.each_with_indexdo|r,idx|r[:pushups_rank]=idx+1coll.update({:id=>r},r,:upsert=>true)coll.save(r)end这种方法确实有效,但这是遍历对象并更新每个对象的最佳方法吗?有没有更好的方法来计算玩家的段位? 最佳答案

c# - MongoDB C# : Update. pullAll 不删除项目

我目前正在使用其C#驱动程序与MongoDB打交道,尝试API中的每种方法(如果他们提供一些例子,这会更好)一个接一个。目前我正在使用Update.PullAll()方法。我正在使用这个POCO对象进行测试:publicclassPerson{publicObjectIdId{get;set;}publicstringFirstname{get;set;}publicstringLastname{get;set;}publicListSkills{get;set;}}publicclassSkill{publicObjectId{get;set;}publicstringName{ge