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
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Let's rename fetchUsernames to fetchAllUsernames before landing.
keyserver/src/fetchers/user-fetchers.js | ||
---|---|---|
377 | Can we rename this to fetchAllUsernames so it's a little clearer + symmetric w/ fetchAllUserIDs above | |
379–383 | 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 | 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 | @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 | ah fair. i'll change this |