added query function to posts service