Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Cleaning up a function?

$
0
0

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;};

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>