小程序开发

使用noneDB查询数据

2020-04-23  本文已影响0人  noneDB

开发参数

数据库名称:nonedb_test

数据库秘钥:000000000000000000000000000000

接口说明

接口地址:https://service.nonedb.com/:database/:collection/find

:database 代表数据库名称,如nonedb_test

:collection 代表数据集,数据存放在数据集内

请求方式

post

参数格式

json

请求参数

字段名 类型 说明 举例
where json 查询条件,键值对格式,键值对必须以键的ASCII码值进行排序 {"phone":16666666666}
timestamp int linux时间戳,精确到秒 1587559144
sign string 签名信息,将values,timestamp拼接后,加上数据库秘钥key计算sha1得到

返回结果

字段名 类型 说明 举例
result_code string success代表成功,fail代表失败
result_desc string 结果描述
data array 查询得到数据结果 ["das"] 或者[{"name":"hello world"}]

示例:从保存用户的数据集profile里面查手机号(phone)为16666666666的用户数据

step1.确定数据库和数据集:数据库nonedb_test ,数据集profile

则对应接口请求地址为:https://service.nonedb.com/nonedb_test/profile/find

step2.确定接口参数内容

where: {"phone":16666666666}

timestamp:1587559144

step3.生成签名串串

对所有非空参数按照键值的英文字母排序,最后拼接上数据库的秘钥key生成签名串 签名串为:

timestamp=1587559144&where={"phone":16666666666}&key=000000000000000000000000000000

step4:计算签名

对签名串进行sha1计算,得到签名 sign为:

63b670dad572b3ccc80ec99593a9b4c34dfc678e

step5:查询数据

发送请求:

curl https://service.nonedb.com/nonedb_test/profile/find -X POST -d '{"where": {"phone":16666666666},"timestamp":1587559144,"sign":"63b670dad572b3ccc80ec99593a9b4c34dfc678e"}' --header "Content-Type: application/json"

收到请求:

{"data":[{"_id":"5ea03ea188e95627ea7c4ad4","nick_name":"hello world","openid":"1","phone":16666666666,"register_timestamp":1587559144},{"_id":"5ea03ead88e95627ea7c4b06","nick_name":"hello world","openid":"1","phone":16666666666,"register_timestamp":1587559144}],"result_code":"success","result_des":"查找成功"}

上一篇 下一篇

猜你喜欢

热点阅读