如何解决ecto:子查询&存在
当表中存在关联时,我想向模型添加一个标志。在我的用户模型中,我具有以下字段:field :is_employed,:boolean,virtual: true,default: false
我可以结合使用select_merge
和exists
吗?
User
|> ...
|> select_merge([u],%{is_employed: Repo.exists(from t in Task,where: u.id == t.user_id and t.status == "in_progress")})
|> Repo.all()
解决方法
std::tuple<char,long long,double,long double,float> some_values(33,2,3.4,5.6,7.8);
constexpr size_t length_of_first_part = 2;
split_apply<length_of_first_part>(
[](auto&&... current_val) {
((std::cout << "(Should be first part) " << current_val << "\n"),...);
},[](auto&&... current_val) {
((std::cout << "(Should be second part) " << current_val << "\n"),...);
},some_values);
解决此问题的一种方法是拥有数据联接,您可以直接使用它们进一步查询适当的数据。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。