From cf5a1485feb7a10c2f3c74500a2de83c0db6191d Mon Sep 17 00:00:00 2001 From: Gabriel Naiman Date: Wed, 28 Sep 2016 12:52:55 -0300 Subject: [PATCH] Collection return nil on update and delete --- lib/rasti/db/collection.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/rasti/db/collection.rb b/lib/rasti/db/collection.rb index 6c8cb90..f07c380 100644 --- a/lib/rasti/db/collection.rb +++ b/lib/rasti/db/collection.rb @@ -79,22 +79,25 @@ def bulk_insert(attributes, options={}) def update(primary_key, attributes) db.transaction do collection_attributes, relations_primary_keys = split_related_attributes attributes - updated_count = dataset.where(self.class.primary_key => primary_key).update(collection_attributes) unless collection_attributes.empty? + dataset.where(self.class.primary_key => primary_key).update(collection_attributes) unless collection_attributes.empty? save_relations primary_key, relations_primary_keys - updated_count + nil end end def bulk_update(attributes, &block) build_query(&block).instance_eval { dataset.update attributes } + nil end def delete(primary_key) dataset.where(self.class.primary_key => primary_key).delete + nil end def bulk_delete(&block) build_query(&block).instance_eval { dataset.delete } + nil end def find(primary_key)