If you’re trying to solve a problem and think “I’ll use mongodb”, well now you’ve got two problems.
Just pick postgres. If you have unstructured data as input, either put in the effort to create some kind of schema for it if you can or just use jsonb if you can’t.