如题:
用户表:user,其中upcode记录的是该用户所属上级的ucode,如表中用户2和4为1的下级
{
"_id": 1,
"ucode": 111,
"uname": "张"
}
{
"_id": 2,
"ucode": 222,
"upcode": 111,
"uname": "王"
}
{
"_id": 3,
"ucode": 333,
"upcode": 222,
"uname": "李"
}
{
"_id: "4,
"ucode": 444,
"upcode": 111,
"uname": "赵"
}
订单表:order
{
"_id": 1,
"ucode": 111,
"orderName": "商品1",
"orderPrice":24
}
{
"_id": 2,
"ucode": 222,
"orderName": "商品1",
"orderPrice":24
}
{
"_id": 3,
"ucode": 333,
"orderName": "商品1",
"orderPrice":24
}
{
"_id": 4,
"ucode": 444,
"orderName": "商品1",
"orderPrice":24
}
{
"_id": 5,
"ucode": 222,
"orderName": "商品1",
"orderPrice":24
}
比如我是ucode为111的用户,现在想要把order表中是我下级用户(222和333)的订单返回来,要怎么实现呢?
2 个回复
DCloud_uniCloud_WYQ
请参考uni-id的裂变进行数据表设计
生涯 - 自学成才
这个很简单吧,生成订单的时候,把自己的标识和上级的标识一块存进去,然后根据下级成员的标识和自己的标识查询遍历不就行了