MCPcopy Create free account
hub / github.com/app-generator/api-server-nodejs / updateUser

Function updateUser

src/update-role.ts:7–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const updatedRole = process.argv[3] ?? "1";
6
7const updateUser = async () => {
8 await connect();
9 const userRepository = connection!.getRepository(User);
10 userRepository.find({ id: userId }).then((user: any) => {
11 if (!user.length) {
12 console.error( "No user exists with the given id" )
13 return;
14 }
15 const query = { id: user[0].id };
16 const newValues = { user_role: updatedRole };
17 userRepository
18 .update(query, newValues)
19 .then(() => console.log(`User updated successfully with role ${newValues.user_role}`)
20 )
21 .catch((err) => console.error(`error in updating user: ${err.message}`)
22 );
23 })
24 .catch((err) => console.log(`error: ${err.message}`)
25 )
26};
27
28updateUser();

Callers 1

update-role.tsFile · 0.85

Calls 1

connectFunction · 0.90

Tested by

no test coverage detected