MongoDB findBy..In与FindBy..Containing

问题描述 投票:1回答:1

我有一些课堂活动:

@Data
@Document(collection = "event")
public class Event {
private String id;
private List<Type> types;
}

现在,我要获取所有在类型中包含某些Type实例的事件。我可以在MongoRepository类中编写两个方法:

List<Event> findByTypesContaining(List<Type> type, Pageable pageable);

List<Event> findByTypesIn(List<Type> type, Pageable pageable);

两者都是作品。当我必须使用...包含和...输入时,它们之间有什么区别?

java mongodb spring-data-mongodb
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.