使用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'>
}
网友评论