我的架构看起来像这样:
CREATE TABLE plans (
id SERIAL PRIMARY KEY,
description text
);
CREATE TABLE projects (
id SERIAL PRIMARY KEY,
project_id character varying(240) UNIQUE,
plan_id integer REFERENCES plans(id) ON DELETE CASCADE
);
我想按照以下方式进行风暴查询
plan = store.find(Plan, Plan.project_id == "alpha")
# should translate to something like
# SELECT p.* from plans p LEFT JOIN projects proj ON p.id = proj.plan_id
# WHERE proj.project_id = 'alpha';
(请注意,这projects.plan_id
不是唯一的。)
我该如何设置?