You can pass a string query path to #all, like this:
Foo.all('config.key1' => 'val1')
Assuming 'config' is the name of the relationship in Foo.
Chris
On 12/11/2011, at 4:47 AM, Jason Hill wrote:
> create table foo (id, name)
> create table foo_config (id, foo_id, key, value)
>
> insert into foo (1, 'name1')
> insert into foo (2, 'name2')
> insert into foo (3, 'name3')
>
> insert into foo_config (1, 1, 'key1', 'val1')
> insert into foo_config (2, 1, 'key2', 'val2')
> insert into foo_config (3, 1, 'key3', 'val3')
> insert into foo_config (4, 2, 'key1', 'val1')
> insert into foo_config (5, 3, 'key2', 'val2')
>
> How do I query for all foo's whose key1 = 'val1', in our case foo:1
> and foo;2 will be listed here. How should I model / query for this,
> appreciate any pointers for the same.
>
> -jh
>
> --
> 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.
>
--
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.