Adds function to build select queries from mongo