ncbo / goo

Graph Oriented Objects (GOO) for Ruby. A RDF/SPARQL based ORM.
http://ncbo.github.io/goo/
Other
15 stars 6 forks source link

Support ActiveModel-type find functionality #28

Closed palexander closed 11 years ago

palexander commented 11 years ago

Supporting a "find" functionality similar to ActiveModel would be great. This will help people familiar with ActiveRecord and other common Ruby ORMs to use Goo a little easier.

I imagine several types of calls:

Person.find(:all)
Person.find(["paul", "manuel"])
Person.find("paul")
Person.find("http://goo.org/metadata/person/paul")
Person.all # wraps Person.find(:all)
Person.where(:name => "paul", :phone => "555-555-5555")

More examples here: http://guides.rubyonrails.org/active_record_querying.html

msalvadores commented 11 years ago

When searching by IRI we need to pass an IRI object ...

Person.find(RDF::IRI.new("http://goo.org/metadata/person/paul"))
msalvadores commented 11 years ago

And for nested objects .... people that live in a country with name Spain ...

Person.where(:lives => { :name => "Spain" })

The same can be achieved in two steps ...

spain = Country.find("Spain")
Person.where(:lives => spain)

Both are supported.