草庐IT

update_at

全部标签

ruby - Mongoid 是否可以覆盖 updated_at 时间戳

我正在尝试通过rake任务手动编辑“updated_at”字段这是它的样子:task:campaigns_updated_at_recovery=>:environmentdoDir.foreach('db/raw-data/campaigns/')do|json|nextifjson=='.'orjson=='..'file=File.read('db/raw-data/campaigns/'+json)data_hash=JSON.parse(file)#pdata_hash["_id"]thisCampaign=Campaign.find(data_hash["_id"])thi

php - 更新 : update() or save()? 的最快方法

我循环浏览我收藏的文档,做一些事情,然后更新数据库。但是,由于我实际上拥有正在更新的文档的所有数据,如果我这样做,save()会比update()更快吗?foreach($cursoras$doc){$doc['new_field']='value';$coll->save($doc);/*or(currently)*/$coll->update(array('known_field'=>$doc['known_field']),array('$set'=>array('new_field'=>'value')));}哪种方式更快? 最佳答案

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

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running

当docker ps出现CannotconnecttotheDockerdaemonatunix:///var/run/docker.sock.Isthedockerdaemonrunning以下报错时,首先systemctlstatusdocker查看docker服务的状态如果处于关闭状态则需要启动docker服务systemctlstartdocker如果服务是启动状态docker  ps还是报这个错vim/usr/lib/systemd/system/docker.service[Unit]Description=DockerApplicationContainerEngineDocum

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

Mysql中关于 错误 1366 - Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘name‘ at row 1

在向数据库中添加英文测试数据时没问题,但是添加中文测试数据时发现一个错误:1366-Incorrectstringvalue:‘\xE5\xBC\xA0\xE4\xB8\x89’forcolumn‘name’atrow1。解释为:1366-字符串值不正确:第1行的列’name’为’\xE5\xBC\xA0\xE4\xB8\x89’出现这个问题的原因是你的数据库编码、排序类型不是utf-8的,所以你创建的表的排序规则自然也不是utf-8类型的。如下:people表是正常支持中文的,user表是错误1366的,看他们排序规则区别。为什么会出现这种情况?在mysql中新建数据库,如果只写数据库名,没

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

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

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

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'

node.js - 无法连接到数据库MongoParseError : Unescaped at-sign in authority section

我正在尝试连接到我的nodeJS项目中的mongodb服务器。我有一个数据库配置文件DB.jsmodule.exports={DB:'mongodb+srv://user%40gmail.com:%24ugar@cluster-jfgsm.mongodb.net/test?retryWrites=true'};用户名包含@(%40)标记,因为它是电子邮件ID,密码包含$(%24)个字符。我已经在我的server.js文件中将其连接为mongoose=require('mongoose'),config=require('./config/DB');constapp=express();