class Cart
include Mongoid::Document
embeds_many :cart_items
def calculate_prices
# Set some fields
end
def remove_item(item)
# what goes here?
calculate_prices
save
end
end
class CartItem
include Mongoid::Document
embedded_in :cart
end
remove_item
カートからカート項目をアトミックに削除し、いくつかの新しい価格をupdate
カート コレクションに設定したいと思います。
それは可能ですか?たぶん、埋め込みアイテムを破棄するようにマークしてからカートを保存するための API でしょうか。