update DocumentRepository to use where expression only when not null