It’s interesting that you lost data. Whenever I’ve used brew to update my version of MongoDB it’s never touched the data directory and the new version comes up just find pointed at the old data storage.

I even just now ran a brew uninstall mongodb-community and my data folder was not deleted. Once I ran brew install mongodb-community and connected via mongosh I was able to see the data.