gets all the usernames from the users table
Details
- Reviewers
atul ashoat - Commits
- rCOMM979c4b4a278e: [keyserver] fetchUsernames helper function
tested with subsequent diff
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Let's rename fetchUsernames to fetchAllUsernames before landing.
keyserver/src/fetchers/user-fetchers.js | ||
---|---|---|
377 ↗ | (On Diff #28170) | Can we rename this to fetchAllUsernames so it's a little clearer + symmetric w/ fetchAllUserIDs above |
379–383 ↗ | (On Diff #28170) | In fetchAllUserIDs, we do: const query = SQL`SELECT id FROM users`; const [result] = await dbQuery(query); return result.map(row => row.id.toString()); can we match that? Up to you |
keyserver/src/fetchers/user-fetchers.js | ||
---|---|---|
379–383 ↗ | (On Diff #28170) | If the result is empty, I think your suggested code will throw an error because you can't call map on undefined. I'm guessing this is fine for id since it's the primary key, but I don't think it is for username |
keyserver/src/fetchers/user-fetchers.js | ||
---|---|---|
379–383 ↗ | (On Diff #28170) | @varun I don't follow your reasoning. If you're afraid that result can be null or undefined, then the same risk occurs on line 380, when you call result.length. In fact, result should never be null or undefined... if dbQuery encounters an error then it will throw, and if it doesn't then result will be an array. |
keyserver/src/fetchers/user-fetchers.js | ||
---|---|---|
379–383 ↗ | (On Diff #28170) | ah fair. i'll change this |