美文网首页
使用wedb访问数据(2)-查询数据

使用wedb访问数据(2)-查询数据

作者: 备考999天 | 来源:发表于2019-12-08 20:01 被阅读0次

使用GET方法查询数据表

以下可以查询表名为table的记录,从0条位置开始,返回30条数据

http://host/wedb/52go/query/<table>

例如,查询user_info的所有字段,从0条位置开始,返回30条数据,可以这样写:

http://host/wedb/52go/query/user_info

查询结果按某个字段排序:

http://host/wedb/52go/query/<table>/<order_by>

例如,查询user_info的所有字段,从0条位置开始,返回30条数据,并以mobile字段排序,可以这样:

http://host/wedb/52go/query/user_info/mobile

查询时,指定开始位置:

http://host/wedb/52go/query/<table>/<order_by>/<int:offset>

例如,查询user_info的所有字段,从31条位置开始,返回30条数据,并以mobile字段排序,可以这样:

http://host/wedb/52go/query/user_info/mobile/31

查询指定返回记录数:

http://host/wedb/52go/query/<table>/<order_by>/<int:offset>/<int:limit>

例如,查询user_info的所有字段,从21条位置开始,返回20条数据,并以mobile字段排序,可以这样:

http://host/wedb/52go/query/user_info/mobile/21/20

查询时指定返回格式:

http://host/wedb/52go/query/<table>/<order_by>/<int:offset>/<int:limit>/<format>

以上format可以是json,csv,msgpack。

例如,查询user_info的所有字段,从21条位置开始,返回20条数据,以mobile字段排序,返回csv,可以这样:

http://host/wedb/52go/query/user_info/mobile/21/20/csv

使用request args指定过滤器:

http://host/wedb/52go/query/<table>/<order_by>/<int:offset>/<int:limit>/<format>?<filter-list>

例如,查询上海的客户

http://host/wedb/52go/query/user_info/mobile/21/20/csv?city=上海

使用POST方法查询数据表

复杂的查询使用POST,格式如下:

URL:http://host/wedb/52go/query

POST BODY

        {

        'table':<string>,

        'filter_by':<{'fieldname1':fieldvalue1,...,'fieldnamen':fieldvaluen}>,

        'order_by':<['fieldname1',....,'fieldnamen']>,

        'offset':<int:default 0>,

        'limit':<int:default 30>,

        'format':<'json'|'csv'|'msgpack'>

        }

上一篇

下一篇

目录

相关文章

网友评论

      本文标题:使用wedb访问数据(2)-查询数据

      本文链接:https://www.haomeiwen.com/subject/uziugctx.html