0

I have such a query executable in the mongo shell:

db.devices.find({_id: {$gt: ObjectId("5fd931e00000000000000000")}})

And I want to write it down in spring boot reactive mongo data, my attempts looking like this were unsuccessful:

   @Service
public class MongoService {
@Autowired
private final ReactiveMongoTemplate mongo;

public MongoService(ReactiveMongoTemplate mongo) {
    this.mongo = mongo;
}

public Flux<Device> getObjectsByTimestamp(String timestamp) {
    Query query = new Query(Criteria.where("_id").gt("5fd931e00000000000000000"));
    return mongo.find(query, Device.class, "devices");
}
}
RideSVEL
  • 1
  • 3

1 Answers1

0

Was able to solve the problem by:

    public Flux<Device> getObjectsByTimestamp(String timestamp) {
    ObjectId objectId = new ObjectId("5fd931e00000000000000000");
    Query query = new Query(Criteria.where("_id").gt(objectId));
    return mongo.find(query, Device.class, "devices");
}
RideSVEL
  • 1
  • 3