Skip to content

Commit e1b53fc

Browse files
committed
review getDatabases
1 parent 475b3aa commit e1b53fc

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

docs/_sidebar.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- [server](api/woqlClient.js?id=server)
1919
- [api](api/woqlClient.js?id=api)
2020
- [organization](api/woqlClient.js?id=organization)
21+
- [getDatabases](api/woqlClient.js?id=getDatabases)
2122
- [user](api/woqlClient.js?id=user)
2223
- [userOrganization](api/woqlClient.js?id=userOrganization)
2324
- [databases](api/woqlClient.js?id=databases)
@@ -58,6 +59,7 @@
5859
- [getEnums](api/woqlClient.js?id=getEnums)
5960
- [getClassDocuments](api/woqlClient.js?id=getClassDocuments)
6061
- [getBranches](api/woqlClient.js?id=getBranches)
62+
- [getUserOrganizations](api/woqlClient.js?id=getUserOrganizations)
6163
- [getDiff](api/woqlClient.js?id=getDiff)
6264
- [patch](api/woqlClient.js?id=patch)
6365
- [WOQL](api/woql.js?id=WOQL)

docs/api/woqlClient.js.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ const client = new TerminusClient.WOQLClient('SERVER_CLOUD_URL/mycloudTeam',
3232
{user:"[email protected]", organization:'mycloudTeam'})
3333

3434
client.setApiKey(MY_ACCESS_TOKEN)
35+
//to get the list of all organization's databases
36+
client.getDatabases(result=>{
37+
console.log(result)
38+
39+
})
3540
async function getSchema() {
3641
client.db("test")
3742
client.checkout("dev")
@@ -303,7 +308,8 @@ let api_url = client.api()
303308
304309
### organization
305310
#### woqlClient.organization([orgId]) ⇒ <code>string</code> \| <code>boolean</code>
306-
Gets/Sets the client’s internal organization context value
311+
Gets/Sets the client’s internal organization context value, if you change the organization name the
312+
databases list will be set to empty
307313
308314
309315
| Param | Type | Description |
@@ -315,6 +321,15 @@ Gets/Sets the client’s internal organization context value
315321
client.organization("admin")
316322
```
317323
324+
### getDatabases
325+
#### woqlClient.getDatabases() ⇒ <code>string</code> \| <code>boolean</code>
326+
Gets the organization's databases list
327+
328+
**Example**
329+
```js
330+
client.getDatabases()
331+
```
332+
318333
### user
319334
#### woqlClient.user() ⇒ <code>Object</code>
320335
Gets the current user object as returned by the connect capabilities response
@@ -851,6 +866,18 @@ get the database collections list
851866
client.getBranches()
852867
```
853868
869+
### getUserOrganizations
870+
#### woqlClient.getUserOrganizations() ⇒ <code>Promise</code>
871+
get the organizations and the database related
872+
873+
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
874+
**Example**
875+
```js
876+
client.getUserOrganizations().then(result=>{
877+
console.log(result)
878+
})
879+
```
880+
854881
### getDiff
855882
#### woqlClient.getDiff(before, after) ⇒ <code>Promise</code>
856883
Get the patch of difference between two documents.

lib/woqlClient.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const { default: axios } = require('axios')
3434
* {user:"myemail@something.com", organization:'mycloudTeam'})
3535
*
3636
* client.setApiKey(MY_ACCESS_TOKEN)
37-
* //to get the list of all the team and databases
37+
* //to get the list of all organization's databases
3838
* client.getDatabases(result=>{
3939
* console.log(result)
4040
*
@@ -145,8 +145,9 @@ WOQLClient.prototype.getDatabases = async function(){
145145
//we'll change this call
146146
await this.getUserOrganizations();
147147
const dbs = this.userOrganizations().find(element => element['name'] === this.connectionConfig.organization())
148-
this.databases(dbs)
149-
return dbs
148+
const dbList = dbs && dbs.databases ? dbs.databases : []
149+
this.databases(dbList)
150+
return dbList
150151
}
151152

152153
/**
@@ -1078,12 +1079,9 @@ WOQLClient.prototype.getBranches = function(dbId){
10781079
this.checkout(branch)
10791080
return branchesObj
10801081
})
1081-
//reset branch
1082-
1082+
//reset branch
10831083
}
10841084

1085-
1086-
10871085
/**
10881086
* get the organizations and the database related
10891087
* @returns {Promise} A promise that returns the call response object, or an Error if rejected.
@@ -1093,7 +1091,7 @@ WOQLClient.prototype.getBranches = function(dbId){
10931091
* })
10941092
*/
10951093
WOQLClient.prototype.getUserOrganizations = function(){
1096-
// return response
1094+
// this will be change to give back only the organizations list
10971095
return this.dispatch(
10981096
CONST.GET,
10991097
this.connectionConfig.userOrganizationsURL(),

0 commit comments

Comments
 (0)