Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4349

Deleting non-persisted embedded subdocuments

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 4.0.0 final
    • Component/s: None
    • Labels:
      None

      Hi
      I have an embeds_many collection and I create a few items. The parent is still not saved (those new items show persisted? == false) and later I decide I want to remove them.
      I tried items.where(...).delete_all and {{new_items.each

      { |i| new_items.delete(i) }

      but both are running $pull queries.
      So my question is: is there a way to delete new (non-persisted) items from an embeds_many without hitting the database?
      Thanks

            Assignee:
            Unassigned Unassigned
            Reporter:
            stanley90x Marek Stanczyk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: