我想在 MongoDB 中实现如下效果(递归查询子节点),可以实现么?
多层级,我想一次性递归查询子节点
用 MongoDB 实现评论和回复存储,schema 优雅的设计应该是怎样的,我想着通过 parentId 和 id 关联
<resultMap id="xxx" type="xxxx">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="pid" jdbcType="BIGINT" property="name" />
<collection property="children" column="id" ofType="xxx" select="selectSubItemByPid"/>
</resultMap>
<select id="selectSubItemByPid" parameterType="xxx" resultMap="xxx">
select * from xxx where pid = #{pid}
</select>