Permalink
Browse files

Updated destroy! to delete via bulk_save.

  • Loading branch information...
1 parent 1da0921 commit 72d36a310e8e36abd85dd72954ee4bc547cf12c8 @paulcarey committed Apr 15, 2010
Showing with 2 additions and 12 deletions.
  1. +2 −12 lib/relaxdb/all_delegator.rb
@@ -37,20 +37,10 @@ def size
size || 0
end
- #
- # TODO - needs updating
- #
- # TODO: destroy in a bulk_save if feasible
def destroy!
load!
- @objs.each do |o|
- # A reload is required for deleting objects with a self referential references_many relationship
- # This makes all.destroy! very slow. Change if needed
- # obj = RelaxDB.load(o._id)
- # obj.destroy!
-
- o.destroy!
- end
+ @objs.each { |o| o.data["_deleted"] = true }
+ RelaxDB.bulk_save! *@objs
end
end

0 comments on commit 72d36a3

Please sign in to comment.