Skip to content

Commit efd9c37

Browse files
feat(store): add updateUser helper
Reuses getUserById and mutates the record in place, returning undefined when the id does not exist so callers decide how to report "not found". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 19e97af commit efd9c37

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

db/store.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,16 @@ function createUser({ name, email }) {
2424
return user;
2525
}
2626

27-
module.exports = { getAllUsers, getUserById, createUser };
27+
function updateUser(id, { name, email }) {
28+
const user = getUserById(id);
29+
30+
if (!user) {
31+
return undefined;
32+
}
33+
34+
user.name = name;
35+
user.email = email;
36+
return user;
37+
}
38+
39+
module.exports = { getAllUsers, getUserById, createUser, updateUser };

0 commit comments

Comments
 (0)