Conversion from MongoDB to PostgreSQL