minapp-fetch
TypeScript icon, indicating that this package has built-in type declarations

3.3.9 • Public • Published

知晓云平台常用接口封装

目前支持的有:

  1. 知晓云:运营后台、云函数、各类小程序、webapi等
  2. 微信小程序云开发uniCloud【少量】

mysqlmongodbredis、等数据库连接,请使用 access-db

使用:

//app.js 
import minapp from 'minapp-fetch'
...
onLaunch: function() {
  minapp.init('zx_weapp')
}


//somePage.js  使用
import minapp from 'minapp-fetch'
minapp.find('tableName', {
  p0: ['num', '=', 0],
  r: 'p0'
}).then(res => {
  
}, err => {})

文档

最新接口文档,可在minapp-fetch官方文档里查看
按需加载配置:按需加载配置文档

优点

统一、简单、高效

下面就以知晓云平台的最简单的and、or复杂组合查寻为例:

/** 原方法 **/
let query1 = new wx.BaaS.Query()
query1.in('color', ['green', 'red', 'yellow'])
let query2 = new wx.BaaS.Query()
query2.compare('price', '>', 10)
let andQuery = wx.BaaS.Query.and(query1, query2)
let query3 = new wx.BaaS.Query()
query3.compare('amount', '>=', 3)
let orQuery = wx.BaaS.Query.or(andQuery, query3)
let Product = new wx.BaaS.TableObject(tableName)
Product.setQuery(orQuery).find().then(res => {
  // success
})


/** minapp-fetch 其他各个平台写法都如下 **/
minapp.find(tableName, {
  p1: ['color', 'in', ['green', 'red', 'yellow']],
  p2: ['price', '>', 10],
  p3: ['amount', '>=', 3],
  r: '(p1 && p2) || p3'
}).then(res => {
  // success
})

Readme

Keywords

Package Sidebar

Install

npm i minapp-fetch

Weekly Downloads

1

Version

3.3.9

License

MIT

Unpacked Size

286 kB

Total Files

165

Last publish

Collaborators

  • fairy_zhao