Mongodb 如何使用mongoid声明一个不存储在DB中的变量?
是否存在某种瞬态,我可以使用非字段,并且仍然在对象中维护,而不在db中存储: 例如:Mongodb 如何使用mongoid声明一个不存储在DB中的变量?,mongodb,mongoid,Mongodb,Mongoid,是否存在某种瞬态,我可以使用非字段,并且仍然在对象中维护,而不在db中存储: 例如: class User dont-store :birthday end 只需使用普通的旧属性访问器 class Customer field :name # this is stored attr_accessor :credit_card # does not get stored end
class User
dont-store :birthday
end
只需使用普通的旧
属性访问器
class Customer
field :name # this is stored
attr_accessor :credit_card # does not get stored
end