MODELS: (not verbatim, but close enough)
Tag:
property :id, Serial
property :name, String
has n, :file_tags
has n, :files, :through => :file_tags
File:
property :id, Serial
property :fname, String
property :location, String
has n, :file_tags
has n, :tags, :through => :file_tags
FileTag:
belongs_to :tag, :key => true
belongs_to :file, :key => true
CODE:
qs = "big red dog"
qry = qs.split(' ')
@results = File.all('tags.name.like' => "%#{qry.shift}%")
qry.each do |q|
@results &= File.all('tags.name.like' => "%#{q}%")
end
Wow DM does so much heavy lifting and removes a lot of tedious query
building.
However I really need to check more than just tag name for a match. I
really need it to do something like this:
WHERE (tag.text like 'param[1]' OR file.fname like 'param[1]') AND
(tag.text like 'param[2]' OR file.fname like 'param[2]') AND (tag.text
like 'param[3]' OR file.fname like 'param[3]')
I gop ethat makes sense
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.