Added where conditions to sql and mongo