Skip to content

Commit

Permalink
fix: db delete key return value (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored Dec 9, 2021
1 parent 62db538 commit 34f5f82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/api/test/mocks/pgrest/patch_auth_key.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"id": 1
}
[{
"id": "1"
}]
6 changes: 5 additions & 1 deletion packages/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,12 @@ export class DBClient {
throw new DBError(error)
}

if (!data.length) {
return undefined
}

return {
_id: data.id
_id: data[0].id
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/db/test/user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ describe('user operations', () => {
const keys = await client.listKeys(user._id)

// Delete previously created key
await client.deleteKey(user._id, authKey._id)
const { _id } = await client.deleteKey(user._id, authKey._id)
assert(_id, 'key deleted')

const finalKeys = await client.listKeys(user._id)
assert(finalKeys, 'final keys fetched')
Expand Down

0 comments on commit 34f5f82

Please sign in to comment.