数据库字段Pointer的操作方法

多数情况下要要是Pointer字段实现了类似传统关系数据库的关联操作,联合查询能够减少提交次数,今天带来几种过滤器的使用方法:

首先确定2个Class,也就是表:

A表:user表,用户个人信息,字段:id,name,nickname,其它字段

B表:word表,用户发言信息,字段:id,title,userId(关联A表,Pointer字段),其它字段

1.查询word表,获得某个用户的所有发言记录。

 由于要关联A表的用户名、昵称等内容,使用filter中的where及include

 var uid=你的用户id
 var filter={
     where:{id:uid},
     include:["userIdPointer"]

}

返回表信息是一个json数组,其中一条记录应该是 {id:"XXXX",name:"BBB",nickname:"XXXX",user:{A表的所有字段}}

2.上述查询中,只需要A表中的name,此时要使用includefilter及对应的fields联合实现关联表的字段选择

   var filter={ where:{id:uid},
     include:["userIdPointer"],//关联的id后加Pointer
     "includefilter":{"user":{"fields":["id","name"]}}//其中id字段必须包含

}

类似的复杂的其它查询可以借鉴操作!

相关技术文档:http://www.apicloud.com/index?uzchannel=2

免费1对1梳理APP需求:http://app.apicloud.com/RequirementDescription

推荐项目送macbook、iphone7等大礼:http://community.apicloud.com/bbs/forum.php?mod=viewthread&tid=44433

enter image description here

收藏 0分享浏览 860
7年前
跟帖
暂无
说几句
广告位 点击查看投放指南

友情链接 大搜车前端团队博客
我的收藏