On Wed, Sep 16, 2009 at 9:00 PM, peter websdell
<[email protected]> wrote:
> Hello all,
> I'm new to Storm and this list.
> I have assumed so far that storm uses lazy-loading to get attributes from
> relations. Is it possible to specify auto loading of related tables? If so,
> can it be done on-the-fly, rather then in the class definition?

When you access a "Reference" attribute on an object, Storm will
perform a store.get() call to retrieve the related object.  If the
object has already been loaded, then it will be returned directly.  If
it hasn't, this will result in a query.

If you want to retrieve pairs of objects in a single query, you can do
that with store.find().  Something like this:

class A(object):
    __storm_table__ = "a"
    id = Int(primary=True)

class B(object):
    __storm_table__ = "b"
    id = Int(primary=True)
    a_id = Int()
    a = Reference(a_id, A.id)

result = store.find((B, A), B.a_id == A.id)
for (b, a) in result:
    # The following won't issue a query, because "a" was loaded at the
same time as "b".
    assert b.a == a

Hope this helps,

James.

-- 
storm mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/storm

Reply via email to