Skip to content

Commit

Permalink
根据 CR 修改文档
Browse files Browse the repository at this point in the history
  • Loading branch information
arcturus011 committed Sep 13, 2018
1 parent b43145c commit 28627ad
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 50 deletions.
11 changes: 6 additions & 5 deletions cloud-function/node-sdk/access-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@

```javascript
{
access_token: '2222',
expires_in: 111
access_token: '13_9cUD6KTQb4qtASzoL_k1uDCWqjOGRfHieF3-aHBahJ5XGjsDAhaoQLf8DWk1lpfm3J76F0LI3E820dMSAkWwnzlq264qxca8M5xBXU7y4e1Ka5IrUMu8zzvei9BFzE4QmXL1yVxwmsp45VhtXTOfABATPK',
expires_in: 5400
}
```

## 示例代码
```javascript
exports.main = function (e, cb) {
BaaS.wxAccessToken(e.signkey).then(res => {
exports.main = function (event, callback) {
BaaS.wxAccessToken(event.signkey).then(res => {
console.log(res)
cb(null, res)
callback(null, res)
}).catch(e => {
console.log(e)
callback(e)
})
}
```
8 changes: 4 additions & 4 deletions cloud-function/node-sdk/censor.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

### 示例代码
```javascript
exports.main = async function (e, cb) {
cb(null, await BaaS.wxCensorImage('5b71568674f0e509bb5ecc30'))
exports.main = async function (event, callback) {
callback(null, await BaaS.wxCensorImage('5b71568674f0e509bb5ecc30'))
}
```
{% endblock censorImageCode %}
Expand All @@ -44,8 +44,8 @@ exports.main = async function (e, cb) {
{% block censorTextCode %}

```javascript
exports.main = async function (e, cb) {
cb(null, await BaaS.wxCensorText('123'))
exports.main = async function (event, callback) {
callback(null, await BaaS.wxCensorText('123'))
}
```

Expand Down
1 change: 1 addition & 0 deletions cloud-function/node-sdk/schema/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ let query = new BaaS.Query()

Product.setQuery(query).count().then(num => {
// success
console.log(num) // 10
}, err => {
// err
})
Expand Down
40 changes: 25 additions & 15 deletions cloud-function/node-sdk/super-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
**示例代码**

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserSuperGroup()
cb(null, await g.create({name: 'aa2', children: [8]}))
exports.main = async function (event, callback) {
let userSuperGroup = new BaaS.UserSuperGroup()
callback(null, await userSuperGroup.create({name: 'aa2', children: [8]}))
}
```

Expand All @@ -32,11 +32,16 @@ exports.main = async function (e, cb) {
**示例代码**

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserSuperGroup()
cb(null, await g.get(11))
exports.main = async function (event, callback) {
let userSuperGroup = new BaaS.UserSuperGroup()
callback(null, await userSuperGroup.get(11))
}
```
**返回示例**

```json
{"children": 1, "id": 16, "name": "a2222", "user_group": [{"id": 17, "name": "vvv"}]}
```

## 修改组集
`userSuperGroup.get(superGroupID)`
Expand All @@ -54,9 +59,9 @@ exports.main = async function (e, cb) {
**示例代码**

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserSuperGroup()
cb(null, await g.update(16, {name: 'a2222', children: [17]}))
exports.main = async function (event, callback) {
let userSuperGroup = new BaaS.UserSuperGroup()
callback(null, await userSuperGroup.update(16, {name: 'a2222', children: [17]}))
}
```

Expand All @@ -66,11 +71,16 @@ exports.main = async function (e, cb) {
**示例代码**

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserSuperGroup()
cb(null, await g.getUserSuperGroupList())
exports.main = async function (event, callback) {
let userSuperGroup = new BaaS.UserSuperGroup()
callback(null, await userSuperGroup.getUserSuperGroupList())
}
```
**返回示例**

```json
{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 2}, "objects": [{"children": 1, "id": 16, "name": "a2222", "user_group": [{"id": 17, "name": "vvv"}]}, {"children": 3, "id": 11, "name": "sup", "user_group": [{"id": 9, "name": "产品经理"}, {"id": 10, "name": "总经理"}, {"id": 13, "name": "测试"}]}]}
```

## 删除组集
`userSuperGroup.delete([id,...])`
Expand All @@ -84,8 +94,8 @@ exports.main = async function (e, cb) {
**示例代码**

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserSuperGroup()
cb(null, await g.delete([15, 16]))
exports.main = async function (event, callback) {
let userSuperGroup = new BaaS.UserSuperGroup()
callback(null, await userSuperGroup.delete([15, 16]))
}
```
56 changes: 30 additions & 26 deletions cloud-function/node-sdk/user-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

**示例代码**
```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
cb(null, await g.get(123))
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
callback(null, await userGroup.get(123))
}
```

Expand Down Expand Up @@ -44,12 +44,16 @@ exports.main = async function (e, cb) {
**示例代码**

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
cb(null, await g.offset(10).limit(20).getUserGroupList({parentID: '11'}))
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
callback(null, await userGroup.offset(10).limit(20).getUserGroupList({parentID: '11'}))
}
```

**返回示例**
```json
{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 5}, "objects": [{"id": 17, "members": 0, "name": "vvv", "parent_id": 16, "super_group": {"id": 16, "name": "a2222"}}, {"id": 13, "members": 0, "name": "测试", "parent_id": 11, "super_group": {"id": 11, "name": "sup"}}, {"id": 10, "members": 19, "name": "总经理", "parent_id": 11, "super_group": {"id": 11, "name": "sup"}}, {"id": 9, "members": 2, "name": "产品经理", "parent_id": 11, "super_group": {"id": 11, "name": "sup"}}, {"id": 8, "members": 6, "name": "程序员", "parent_id": null, "super_group": {"id": null, "name": null}}]}
```

## 创建用户组
`userGroup.create({name,parent})`
Expand All @@ -63,10 +67,10 @@ exports.main = async function (e, cb) {

**示例代码**
```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
console.log(await g.create({name: '测试',parent:'11'}))
cb(null)
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
console.log(await userGroup.create({name: '测试',parent:'11'}))
callback(null)
}
```

Expand All @@ -82,10 +86,10 @@ exports.main = async function (e, cb) {

**示例代码**
```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
await g.update(12, {name: '888'})
cb(null)
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
await userGroup.update(12, {name: '888'})
callback(null)
}
```

Expand All @@ -100,10 +104,10 @@ exports.main = async function (e, cb) {

**示例代码**
```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
await g.delete([12, 13])
cb(null)
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
await userGroup.delete([12, 13])
callback(null)
}
```

Expand All @@ -119,10 +123,10 @@ exports.main = async function (e, cb) {

**示例代码**
```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
await g.addUserIntoGroup([1092612, 1092601], [8, 9])
cb(null)
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
await userGroup.addUserIntoGroup([1092612, 1092601], [8, 9])
callback(null)
}
```

Expand All @@ -137,9 +141,9 @@ exports.main = async function (e, cb) {
| groups | integer Array | Y | 用户组 ID 数组|

```javascript
exports.main = async function (e, cb) {
let g = new BaaS.UserGroup()
await g.removeUserFromGroup([1092612], [8, 9])
cb(null)
exports.main = async function (event, callback) {
let userGroup = new BaaS.UserGroup()
await userGroup.removeUserFromGroup([1092612], [8, 9])
callback(null)
}
```

0 comments on commit 28627ad

Please sign in to comment.