【问题标题】:Has mongoid replacement for rails save(touch: false)有轨道保存的 mongoid 替代品(触摸:假)
【发布时间】:2020-08-25 12:07:33
【问题描述】:
【问题讨论】:
标签:
ruby-on-rails
mongoid
【解决方案1】:
没有:(
我不认为它是朋友!
我是如何检查的:
- 下载源代码并使用
grep搜索。
git clone https://github.com/mongodb/mongoid.git
可持久化的实例方法都使用选项哈希,我看不到任何提及 touch 选项。
- 在https://docs.mongodb.com/mongoid/7.1/tutorials/mongoid-persistence/index.html 的文档中搜索
一种潜在的解决方法
这是我快速输入的伪代码,因为我从内存中不知道 Mongoid 的 DSL,它基于 ActiveRecord。
object = Object.find(1)
update = object.updated_at
object.update(update_the_object: :attributes_you_want_to)
# Use a method that doesn't update timestamps automatically to, well, update the timestamps.
object.update_column(updated_at: update)