node-ebaas

1.3.1 • Public • Published

node-ebaas

ele baas node sdk

install

npm install node-ebaas

use

const Baas = require('node-ebaas');
 
const APPID = '59192c5984a2fc6c74675dbd';
const TABLE = 'docs';
 
const DocModel = new Baas(APPID, TABLE);
 
let docs = await DocModel.find();
 

init

 
new Baas(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

find(query) -> find(query, headers)

使用例子:

const AppModel = new Baas(APPID, TABLE, config);
 
const headers = {
  Cookie: 'COFFEE_TOKEN=[YOU_COFFEE_TOKEN]'
};
 
await AppModel.find(null, headers);

注意,这里因为 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() 后生效

Readme

Keywords

none

Package Sidebar

Install

npm i node-ebaas

Weekly Downloads

13

Version

1.3.1

License

MIT

Last publish

Collaborators

  • antsword
  • geemo
  • lellansin