On Mon, Jan 5, 2009 at 08:50, Andy Grover <[email protected]> wrote:
>
> Hi, I'm porting my app from SQLObject. Given the model below:
>
> class Event(Entity):
>    date = Field(DateTime)
>
> class Person(Entity):
>    events = ManyToMany("Event")
>
>    @property
>    def future_events(self):
>        # what goes here?
>
> I would like to create a property for Person that takes a relationship
> and then further filters it (e.g. in the above example, by date.) In
> SO I'd define the relation as a SQLRelatedJoin so that a.events would
> return a QueryObj instead of an actual list, so I could do "return
> self.events.filter(Event.q.date >= date.today())"
>
> What would be the recommended way to do this with Elixir, or perhaps
> this is an SO-centric pattern that there's a better way to do with SA/
> Elixir?

You are probably looking for lazy="dynamic". See:

http://www.sqlalchemy.org/docs/05/ormtutorial.html#building-a-relation
and
http://www.sqlalchemy.org/docs/05/mappers.html#dynamic-relation-loaders

Note that dynamic_loader() is not supported in Elixir (but you can use
lazy="dynamic" which does the same thing).

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to