开发者

Is there an equivalent of ActiveRecord's find(:include) in Elixir/SQLAlchemy?

I had been using ActiveRecord previously and it allowed to load all associations of an object using an optional :include argument to its dynamic finders. I have recentl开发者_JS百科y started using Elixir for a python project and am unable to find any documentation that'd suggest if it's possible to do the same.


Using plain SQLAlchemy (without Elixir): http://www.sqlalchemy.org/docs/orm/loading.html

I assume you can configure the loading strategies using Elixir as well, but I have never used it.

EDIT 1:

According to the Elixir documentation, options to the relationship constructs (for instance ManyToOne) can include options that are passed directly to the SQLAlchemy relation (relationship if version >= 0.6) function. That means you can specify the lazy option to control the loading for associated objects.

I assume that Elixir's query method is a thin wrapper around SQLAlchemy's. In that case, you can also control lazy/eager loading for individual queries. See the documentation.

EDIT 2:

Have you considered using sqlalchemy.ext.declarative instead of Elixir?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜