MongoMapper 中的键名称冲突
我在 sinatra 服务中使用 mongo mapper (0.8.6)。我有一个问题,堆栈级别太深。问题是我的模型中的关键“changes
”存在冲突。这是我的模型:
class ChangeLog
include MongoMapper::Document
belongs_to :resource
key :changes, Hash, :required => true
key :message, String, :required => true
key :note, String
key :user_uuid, String, :required => true
key :user_name, String, :required => true
timestamps!
end
但是,我不想重命名我的密钥,因为在本例中,它是我的 Web 服务的正确名称。有什么建议吗?
I use mongo mapper (0.8.6) in my sinatra service. I have one problem with stack level too deep. The problem is that there is conflict of the key "changes
" in my model. Here is my model:
class ChangeLog
include MongoMapper::Document
belongs_to :resource
key :changes, Hash, :required => true
key :message, String, :required => true
key :note, String
key :user_uuid, String, :required => true
key :user_name, String, :required => true
timestamps!
end
However, I don't want to rename my key as in this case, it's the right name for my web service. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
changes
是一个实例方法,它会告诉您自上次保存文档以来哪些字段发生了更改。这是 MongoMapper 文档 中的示例不幸的是,您可能需要选择不同的该字段的名称。也许是“调整”或“变化”或“差异”或“修改”?
changes
is an instance method that will tell you what fields have changed since you last saved the document. Here's an example from MongoMapper's documentationUnfortunately, you're probably going to need to choose a different name for that field. Maybe "adjustments" or "variations" or "differences" or "modifications"?