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

Deleting non-persisted embedded subdocuments

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 12_01_17
    • 4.0.0 final
    • None
    • None

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: