[Nitro] Complex selections

George Moschovitis george.moschovitis at gmail.com
Wed Mar 23 03:35:39 EST 2005

> I have an app (well, I'm learning Nitro/Og as I write it) that has a
> fairly simple object model.
> ...
> I want to be able to select a set of resources that have one or more
> tags with a given name.

Hmm I am planning to use Nitro for something like this :)

> Probably not the most efficient way to do this, and almost certainly not
> correct Og-speak.
> ...
> In my first go-round with Rails (where I first implemented this), I did
> not find any nice Ruby-based way to do this, and ended up falling back
> on assorted SQL (and running into various issues with subselect and MySQL).

Can you suggest an API for this? I dont have something available, but
I would like to add this functionality. Can you post the SQL query you
would actually use and then we can extract some kind of API.

Btw this is similar to another feature I want to add: join queries.

Let me demonstrate with an example.

class User
 property :name, String
 has_many :comments, Comment

class Comment
 property :username, :join => User, :property => :name
 belongs_to :user, User

u = User['george']

for c in u.comments(:join => User)
  puts c.username

the property :username in Comment is a virtual field not actually stored
in the database. I am not that happy with this API though. Does somenone
have any suggestions for this?



More information about the Nitro-general mailing list