lib/neo4j/active_node/orm_adapter.rb in neo4j-3.0.0.alpha.7 vs lib/neo4j/active_node/orm_adapter.rb in neo4j-3.0.0.alpha.8

- old
+ new

@@ -35,30 +35,25 @@ def find_first(options = {}) conditions, order = extract_conditions!(options) extract_id!(conditions) order = hasherize_order(order) - if !order.empty? - klass.find(conditions: conditions, order: order) - else - result = klass.find(conditions: conditions) - result - end + result = klass.where(conditions) + result = result.order(order) unless order.empty? + result.first end # Find all models matching conditions def find_all(options = {}) conditions, order, limit, offset = extract_conditions!(options) extract_id!(conditions) order = hasherize_order(order) - result = if !order.empty? - klass.all(conditions: conditions, order: order, limit: limit, skip: offset) - else - klass.all(conditions: conditions) - end - + result = klass.where(conditions) + result = result.order(order) unless order.empty? + result = result.skip(offset) if offset + result = result.limit(limit) if limit result.to_a end # Create a model using attributes def create!(attributes = {}) @@ -76,10 +71,10 @@ (order || []).map {|clause| Hash[*clause] } end def extract_id!(conditions) if id = conditions.delete(:id) - conditions['id(n)'] = id.to_i + conditions[:neo_id] = id.to_i end end end end