Skip to content

Commit a92b23b

Browse files
vitaly-tdrew-gross
authored andcommitted
Update PostgresStorageAdapter.js (#2093)
If it really needs to reject with `undefined`, then this is the right way. Usually one just returns the result, let the caller provide the `.catch` ;) This way real errors can be swallowed, not very good ;)
1 parent a55466f commit a92b23b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,9 @@ export class PostgresStorageAdapter {
220220
// this adapter doesn't know about the schema, return a promise that rejects with
221221
// undefined as the reason.
222222
getClass(className) {
223-
return this._client.query('SELECT * FROM "_SCHEMA" WHERE "className"=$<className>', { className })
224-
.then(result => {
225-
if (result.length === 1) {
226-
return result[0].schema;
227-
} else {
223+
return this._client.one('SELECT * FROM "_SCHEMA" WHERE "className"=$<className>', { className }, res=>res.schema)
224+
.catch(error => {
228225
throw undefined;
229-
}
230226
});
231227
}
232228

0 commit comments

Comments
 (0)