Skip to content

Commit 0b4c90f

Browse files
authored
Merge pull request #19 from codenotary/feat/sql-describe
chore: add sql describe
2 parents 931d3cf + 712c778 commit 0b4c90f

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules/
22
package-lock.json
33
root.json
44
tests/immudb
5+
tests/test-data
56
.nyc_output
67
.vscode/
78
tests/root.json
@@ -10,4 +11,4 @@ root
1011
rootfile
1112
examples/.env
1213
.env
13-
dist/
14+
dist/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"@typescript-eslint/parser": "^3.9.0",
2929
"crypto-ts": "^1.0.2",
3030
"grpc": "^1.24.10",
31-
"grpc-tools": "^1.11.1",
3231
"grpc_tools_node_protoc_ts": "^5.0.1",
32+
"grpc-tools": "^1.11.1",
3333
"protobufjs": "6.10.1",
3434
"tap": "15.0.9",
3535
"typescript": "^3.9.7"

src/client.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,39 @@ class ImmudbClient {
17621762
console.error(err);
17631763
}
17641764
}
1765+
1766+
async SQLDescribe(tableName: string) {
1767+
const request = new schemaTypes.Table();
1768+
request.setTablename(tableName);
1769+
1770+
return new Promise((resolve, reject) => {
1771+
return this.client.describeTable(request, this._metadata,(err, res) => {
1772+
if (err) {
1773+
console.error('SQLDescribe', err);
1774+
reject(err);
1775+
} else {
1776+
resolve(
1777+
res
1778+
.getRowsList()
1779+
.map(row => row
1780+
.getValuesList()
1781+
.map(value => value.hasNull()
1782+
? value.getNull()
1783+
: value.hasS()
1784+
? value.getS()
1785+
: value.hasN()
1786+
? value.getN()
1787+
: value.hasB()
1788+
? value.getB()
1789+
: value.hasBs()
1790+
? value.getBs_asU8()
1791+
: null)
1792+
))
1793+
1794+
}
1795+
})
1796+
})
1797+
}
17651798
}
17661799

17671800
export default ImmudbClient;

tests/tap-parallel-not-ok/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ tap.test('[OPERATIONS]: SQL', async t => {
471471
params: { name: 'Joe' }
472472
})
473473

474+
await immudbClient.SQLDescribe(tableName)
475+
474476
t.end();
475477
} catch (err) {
476478
t.error(err);

0 commit comments

Comments
 (0)