Skip to content

Commit

Permalink
Collection return nil on update and delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Naiman committed Sep 28, 2016
1 parent 80936a4 commit cf5a148
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rasti/db/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cf5a148

Please sign in to comment.