Skip to content

Commit cb32946

Browse files
committed
add getDatabases and review documentation
1 parent e1b53fc commit cb32946

File tree

3 files changed

+101
-74
lines changed

3 files changed

+101
-74
lines changed

docs/_sidebar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
- [api](api/woqlClient.js?id=api)
2020
- [organization](api/woqlClient.js?id=organization)
2121
- [getDatabases](api/woqlClient.js?id=getDatabases)
22+
- [databases](api/woqlClient.js?id=databases)
2223
- [user](api/woqlClient.js?id=user)
2324
- [userOrganization](api/woqlClient.js?id=userOrganization)
24-
- [databases](api/woqlClient.js?id=databases)
25-
- [userOrganizations](api/woqlClient.js?id=userOrganizations)
2625
- [databaseInfo](api/woqlClient.js?id=databaseInfo)
2726
- [db](api/woqlClient.js?id=db)
2827
- [setSystemDb](api/woqlClient.js?id=setSystemDb)
@@ -60,6 +59,7 @@
6059
- [getClassDocuments](api/woqlClient.js?id=getClassDocuments)
6160
- [getBranches](api/woqlClient.js?id=getBranches)
6261
- [getUserOrganizations](api/woqlClient.js?id=getUserOrganizations)
62+
- [userOrganizations](api/woqlClient.js?id=userOrganizations)
6363
- [getDiff](api/woqlClient.js?id=getDiff)
6464
- [patch](api/woqlClient.js?id=patch)
6565
- [WOQL](api/woql.js?id=WOQL)

docs/api/woqlClient.js.md

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

3434
client.setApiKey(MY_ACCESS_TOKEN)
35+
3536
//to get the list of all organization's databases
36-
client.getDatabases(result=>{
37-
console.log(result)
37+
async function callGetDatabases(){
38+
const dbList = await client.getDatabases()
39+
console.log(dbList)
40+
}
3841

39-
})
4042
async function getSchema() {
4143
client.db("test")
4244
client.checkout("dev")
@@ -323,53 +325,47 @@ client.organization("admin")
323325
324326
### getDatabases
325327
#### woqlClient.getDatabases() ⇒ <code>string</code> \| <code>boolean</code>
326-
Gets the organization's databases list
328+
Gets the organization's databases list.
329+
330+
If no organization has been set up, the function throws an exception
327331
328332
**Example**
329333
```js
330-
client.getDatabases()
334+
async function callGetDatabases(){
335+
const dbList = await client.getDatabases()
336+
console.log(dbList)
337+
}
331338
```
332339
333-
### user
334-
#### woqlClient.user() ⇒ <code>Object</code>
335-
Gets the current user object as returned by the connect capabilities response
336-
user has fields: [id, name, notes, author]
337-
338-
339-
### userOrganization
340-
#### woqlClient.userOrganization() ⇒ <code>string</code>
341-
**Returns**: <code>string</code> - the user organization name
342-
**Desription**: Gets the user's organization id
343-
344340
### databases
345341
#### woqlClient.databases([dbList]) ⇒ <code>array</code>
346-
Retrieves a list of databases (id, organization, label, comment) that the current user has access to on the server.
342+
Set/Get the organization's databases list (id, label, comment) that the current user has access to on the server.
347343
348-
**Returns**: <code>array</code> - the user databases list
344+
**Returns**: <code>array</code> - the organization's databases list
349345
350346
| Param | Type | Description |
351347
| --- | --- | --- |
352348
| [dbList] | <code>array</code> | a list of databases the user has access to on the server, each having: |
353349
354350
**Example**
355351
```js
356-
const my_dbs = client.databases()
352+
//to get the list of all organization's databases
353+
async function callGetDatabases(){
354+
await client.getDatabases()
355+
console.log(client.databases())
356+
}
357357
```
358358
359-
### userOrganizations
360-
#### woqlClient.userOrganizations([orgList]) ⇒ <code>array</code>
361-
Retrieves a list of databases (id, organization, label, comment) that the current user has access to on the server.
362-
363-
**Returns**: <code>array</code> - the user databases list
359+
### user
360+
#### woqlClient.user() ⇒ <code>Object</code>
361+
Gets the current user object as returned by the connect capabilities response
362+
user has fields: [id, name, notes, author]
364363
365-
| Param | Type | Description |
366-
| --- | --- | --- |
367-
| [orgList] | <code>array</code> | a list of databases the user has access to on the server, each having: |
368364
369-
**Example**
370-
```js
371-
const my_dbs = client.databases()
372-
```
365+
### userOrganization
366+
#### woqlClient.userOrganization() ⇒ <code>string</code>
367+
**Returns**: <code>string</code> - the user organization name
368+
**Desription**: Gets the user's organization id
373369
374370
### databaseInfo
375371
#### woqlClient.databaseInfo([dbId]) ⇒ <code>object</code>
@@ -868,14 +864,33 @@ client.getBranches()
868864
869865
### getUserOrganizations
870866
#### woqlClient.getUserOrganizations() ⇒ <code>Promise</code>
871-
get the organizations and the database related
867+
Get the list of the user's organizations and the database related
872868
873869
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
874870
**Example**
875871
```js
876-
client.getUserOrganizations().then(result=>{
877-
console.log(result)
878-
})
872+
async funtion callGetUserOrganizations(){
873+
await getUserOrganizations()
874+
console.log(client.userOrganizations())
875+
}
876+
```
877+
878+
### userOrganizations
879+
#### woqlClient.userOrganizations([orgList]) ⇒ <code>array</code>
880+
Get/Set the list of the user's organizations (id, organization, label, comment).
881+
882+
**Returns**: <code>array</code> - the user Organizations list
883+
884+
| Param | Type | Description |
885+
| --- | --- | --- |
886+
| [orgList] | <code>array</code> | a list of user's Organization |
887+
888+
**Example**
889+
```js
890+
async funtion callGetUserOrganizations(){
891+
await client.getUserOrganizations()
892+
console.log(client.userOrganizations())
893+
}
879894
```
880895
881896
### getDiff

lib/woqlClient.js

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ const { default: axios } = require('axios')
3434
* {user:"myemail@something.com", organization:'mycloudTeam'})
3535
*
3636
* client.setApiKey(MY_ACCESS_TOKEN)
37+
*
3738
* //to get the list of all organization's databases
38-
* client.getDatabases(result=>{
39-
* console.log(result)
39+
* async function callGetDatabases(){
40+
* const dbList = await client.getDatabases()
41+
* console.log(dbList)
42+
* }
4043
*
41-
* })
4244
* async function getSchema() {
4345
* client.db("test")
4446
* client.checkout("dev")
@@ -131,10 +133,15 @@ WOQLClient.prototype.organization = function(orgId) {
131133
}
132134

133135
/**
134-
* Gets the organization's databases list
136+
* Gets the organization's databases list.
137+
*
138+
* If no organization has been set up, the function throws an exception
135139
* @returns {string | boolean}
136140
* @example
137-
* client.getDatabases()
141+
* async function callGetDatabases(){
142+
* const dbList = await client.getDatabases()
143+
* console.log(dbList)
144+
* }
138145
*/
139146
WOQLClient.prototype.getDatabases = async function(){
140147
// return response
@@ -150,6 +157,23 @@ WOQLClient.prototype.getDatabases = async function(){
150157
return dbList
151158
}
152159

160+
/**
161+
* Set/Get the organization's databases list (id, label, comment) that the current user has access to on the server.
162+
* @param {array} [dbList] a list of databases the user has access to on the server, each having:
163+
* @returns {array} the organization's databases list
164+
* @example
165+
* //to get the list of all organization's databases
166+
* async function callGetDatabases(){
167+
* await client.getDatabases()
168+
* console.log(client.databases())
169+
* }
170+
*
171+
*/
172+
WOQLClient.prototype.databases = function(dbList) {
173+
if (dbList) this.databaseList = dbList
174+
return this.databaseList || []
175+
}
176+
153177
/**
154178
* Gets the current user object as returned by the connect capabilities response
155179
* user has fields: [id, name, notes, author]
@@ -170,32 +194,6 @@ WOQLClient.prototype.userOrganization = function() {
170194
}
171195

172196

173-
/**
174-
* Retrieves a list of databases (id, organization, label, comment) that the current user has access to on the server.
175-
* @param {array} [dbList] a list of databases the user has access to on the server, each having:
176-
* @returns {array} the user databases list
177-
* @example
178-
* const my_dbs = client.databases()
179-
*/
180-
WOQLClient.prototype.databases = function(dbList) {
181-
if (dbList) this.databaseList = dbList
182-
return this.databaseList || []
183-
}
184-
185-
/**
186-
* Retrieves a list of databases (id, organization, label, comment) that the current user has access to on the server.
187-
* @param {array} [orgList] a list of databases the user has access to on the server, each having:
188-
* @returns {array} the user databases list
189-
* @example
190-
* const my_dbs = client.databases()
191-
*/
192-
WOQLClient.prototype.userOrganizations = function(orgList) {
193-
if (orgList) this.organizationList = orgList
194-
return this.organizationList || []
195-
}
196-
197-
198-
199197
/**
200198
* Gets the database's details
201199
* @param {string} [dbId] - the datbase id
@@ -220,8 +218,6 @@ WOQLClient.prototype.db = function(dbId) {
220218
this.connectionConfig.setDB(dbId)
221219
}
222220
return this.connectionConfig.dbid
223-
224-
//this.connectionConfig.db()
225221
}
226222

227223
/**
@@ -1083,12 +1079,13 @@ WOQLClient.prototype.getBranches = function(dbId){
10831079
}
10841080

10851081
/**
1086-
* get the organizations and the database related
1082+
* Get the list of the user's organizations and the database related
10871083
* @returns {Promise} A promise that returns the call response object, or an Error if rejected.
10881084
* @example
1089-
* client.getUserOrganizations().then(result=>{
1090-
* console.log(result)
1091-
* })
1085+
* async funtion callGetUserOrganizations(){
1086+
* await getUserOrganizations()
1087+
* console.log(client.userOrganizations())
1088+
* }
10921089
*/
10931090
WOQLClient.prototype.getUserOrganizations = function(){
10941091
// this will be change to give back only the organizations list
@@ -1102,6 +1099,21 @@ WOQLClient.prototype.getBranches = function(dbId){
11021099
})
11031100
}
11041101

1102+
/**
1103+
* Get/Set the list of the user's organizations (id, organization, label, comment).
1104+
* @param {array} [orgList] a list of user's Organization
1105+
* @returns {array} the user Organizations list
1106+
* @example
1107+
* async funtion callGetUserOrganizations(){
1108+
* await client.getUserOrganizations()
1109+
* console.log(client.userOrganizations())
1110+
* }
1111+
*/
1112+
WOQLClient.prototype.userOrganizations = function(orgList) {
1113+
if (orgList) this.organizationList = orgList
1114+
return this.organizationList || []
1115+
}
1116+
11051117
/**
11061118
* Get the patch of difference between two documents.
11071119
* @param {object} before - The current state of JSON document

0 commit comments

Comments
 (0)