i'm new to react and i was wondering if there was a way that i could clean up this function to make it more simple? What i'm trying to do is update a user by finding it in my database for the user in that city.
const registerUser = async (user: string, city: Cities[]): Promise<Cities | null> => { const updatedUser = await db.User.findOneAndUpdate({ name: user }, { $addToSet: { city: cities } }, { new: true }); // this line return updatedUser?.city.find((c: Cities) => c.id == city.id) ?? null;};