node-ebaas
ele baas node sdk
install
npm install node-ebaas
use
const Baas = ;const APPID = '59192c5984a2fc6c74675dbd';const TABLE = 'docs';const DocModel = APPID TABLE;let docs = await DocModel;
init
APPID TABLE config;
config[optional]
-
env(string) alpha/alta/altb/production (default: production)
-
secue(boolean) https 或者 http (default: true)
-
debug(boolean) (default: false)
-
host(string) custom host, example: baas.ele.me (default: null)
method
所有函数最后一个参数可以传递 headers
->
使用例子:
const AppModel = APPID TABLE config; const headers = Cookie: 'COFFEE_TOKEN=[YOU_COFFEE_TOKEN]'; await AppModel;
注意,这里因为 find 的第一个参数是 queryObject,所以为了保证 headers 是在最后一个参数,第一个参数不能省略
Model
find(query)
查询
count(query)
计数
findById(_id)
根据 _id 查询
create(body)
创建
update(_id, body)
更新
remove(_id)
删除
Instance
save()
更新保存
update(body)
更新保存
detroy()
删除
inc(key, value)
增减操作,save() 后生效