Skip to content

Commit 05b2787

Browse files
committed
Improved table display in Pongo shell to show all columns
1 parent a625c7a commit 05b2787

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@event-driven-io/pongo-core",
3-
"version": "0.16.0-alpha.9",
3+
"version": "0.16.0-alpha.11",
44
"description": "Pongo - Mongo with strong consistency on top of Postgres",
55
"type": "module",
66
"engines": {

src/packages/dumbo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@event-driven-io/dumbo",
3-
"version": "0.12.0-alpha.9",
3+
"version": "0.12.0-alpha.11",
44
"description": "Dumbo - tools for dealing with PostgreSQL",
55
"type": "module",
66
"scripts": {

src/packages/pongo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@event-driven-io/pongo",
3-
"version": "0.16.0-alpha.9",
3+
"version": "0.16.0-alpha.11",
44
"description": "Pongo - Mongo with strong consistency on top of Postgres",
55
"type": "module",
66
"scripts": {
@@ -87,7 +87,7 @@
8787
"pongo": "./dist/cli.js"
8888
},
8989
"peerDependencies": {
90-
"@event-driven-io/dumbo": "0.12.0-alpha.9",
90+
"@event-driven-io/dumbo": "0.12.0-alpha.11",
9191
"@types/mongodb": "^4.0.7",
9292
"@types/pg": "^8.11.6",
9393
"@types/uuid": "^10.0.0",

src/packages/pongo/src/commandLine/shell.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ const displayResultsAsTable = (results: any[]): string => {
4949
return chalk.yellow('No documents found.');
5050
}
5151

52-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
53-
const columnNames = Object.keys(results[0]);
52+
const columnNames = results
53+
54+
.flatMap((result) =>
55+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
56+
typeof result === 'object' ? Object.keys(result) : typeof result,
57+
)
58+
.filter((value, index, array) => array.indexOf(value) === index);
5459

5560
const columnWidths = calculateColumnWidths(results, columnNames);
5661

@@ -63,7 +68,18 @@ const displayResultsAsTable = (results: any[]): string => {
6368
table.push(
6469
columnNames.map((col) =>
6570
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
66-
result[col] !== undefined ? String(result[col]) : '',
71+
result[col] !== undefined
72+
? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
73+
Array.isArray(result[col])
74+
? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
75+
displayResultsAsTable(result[col])
76+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
77+
prettyJson(result[col])
78+
: typeof result === 'object'
79+
? ''
80+
: result != undefined && result != undefined
81+
? prettyJson(result)
82+
: '',
6783
),
6884
);
6985
});
@@ -102,7 +118,7 @@ const startRepl = async (options: {
102118
setLogLevel(process.env.DUMBO_LOG_LEVEL ?? options.logging.logLevel);
103119
setLogStyle(process.env.DUMBO_LOG_STYLE ?? options.logging.logStyle);
104120

105-
console.log(chalk.green('Starting Pongo Shell (version: 0.16.0-alpha.9)'));
121+
console.log(chalk.green('Starting Pongo Shell (version: 0.16.0-alpha.11)'));
106122

107123
const connectionString =
108124
options.connectionString ??

0 commit comments

Comments
 (0)