I have added the mongodb dependencies in my spring boot app however I am getting undefined error on "where" method:
ChangeStreamRequest<Person> request = ChangeStreamRequest.builder()
.collection("person")
.filter(newAggregation(Person.class, match(where("operationType").is("insert"))))
.publishTo(pListener)
.build();
POM configuration:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
Please advise me on this
The reason for "undefined" is "there is no method where
defined in your class".
You have to import where
method from Criteria
.
You can use Criteria.where("operationType").is("insert")
by adding the below import statement.
import org.springframework.data.mongodb.core.query.Criteria;
Alternatively you can add a static import as below:
import static org.springframework.data.mongodb.core.query.Criteria.where;
Now, you can directly use :
where("operationType").is("insert")