-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
查询功能要求
查询我关注的节点
返回完整的我关注的节点。
排序注意点:
- 如果按时间排序的话,则按关注的时间排序。即按
UserNodeStar.created排序。 - 如果按节点活跃时间排序则需要按
Node.updated排序。 - 如果按活跃度排序,则需要按
Node.active_degree来排序。
从排序需求来看,原 Node 节点需要增加 active_degree 这个字段。
对于查询语句来说,查询语句不能使用单表查询+子查询的方式。
因为排序需要用到关联表的 UserNodeStar.created 字段。
从逻辑上来说以 Node 作为主表,而以 UserNodeStar 作为右关联表。
那么下面是一个以关注时间进行排序的 SQL:
select node.* ,link.created,link.user_id
from wepost_posts_node as node
left outer join wepost_posts_usernodestar as link on node.id = link.node_id and link.user_id == 43
where link.user_id = 43
order by link.created这里使用了 left outer join 是因为如果使用内联接的话,查询集将太大。
在关联条件中的 on node.id = link.node_id and link.user_id == 43 这是为了减少 关联集的大小。
因为wepost_posts_usernodestar 是记录所有人对所有节点的关注
Reactions are currently unavailable