// Assuming you have connected to the PostgreSQL database // Function to retrieve character profiles based on filters function searchCharacterProfiles(filters) { // Build the SQL query based on the provided filters let query = 'SELECT * FROM character_profiles WHERE 1 = 1'; if (filters.race) { query += ` AND race = '${filters.race}'`; } if (filters.homeworld) { query += ` AND homeworld = '${filters.homeworld}'`; } if (filters.assignment) { query += ` AND assignment = '${filters.assignment}'`; } if (filters.rank) { query += ` AND rank = '${filters.rank}'`; } if (filters.maritalStatus) { query += ` AND marital_status = '${filters.maritalStatus}'`; } // Execute the SQL query // Code for executing the query and retrieving the character profiles goes here // Return the results // Code for processing and returning the character profiles goes here } // Usage example: const filters = { race: 'Human', homeworld: 'Earth', assignment: 'Solaris Station', rank: 'Captain', maritalStatus: 'Single' }; searchCharacterProfiles(filters);