Creating a reactive repository
So far, we have been dabbling with Spring Data using our sample domain of employees. We need to shift our focus back to the social media platform that we started building in the previous chapter.
Before we can work on a reactive repository, we need to revisit the Image
domain object we defined in the last chapter. Let's adjust it so that it works nicely with MongoDB:
@Data @Document public class Image {
Â
Â
Â
Â
@Id final private String id; final private String name; }
This preceding definition is almost identical to what we saw in the previous chapter, with the following differences:
- We use
@Document
to identify this is a MongoDB domain object, but we accept Spring Data MongoDB's decision about what to name the collection (it's the short name of the class, lowercase, that is,image
) @Data
creates a constructor for all final fields by default, hence, we've marked bothid
andname
asfinal
- We have also marked both fields
private
for proper...