The best approach would be:
- Get an array of all of the post IDs in the database.
- Get an array of all of the post IDs that the user has rated (as you have done in your example)
- Remove the IDs in step 2 from step 1 – you’ll then have an array of all unrated post IDs by that user.