簡體   English   中英

如何在不使用 mongoTemplate.executeCommand(..) 的情況下使用 spring-data-mongodb 創建視圖?

[英]How do I create a view using spring-data-mongodb without resorting to mongoTemplate.executeCommand(..)?

所以我知道如何使用mongoTemplate.executeCommand(..)創建視圖 但是,這讓我不得不在字符串中定義視圖。

Spring-data-mongodb 允許使用Aggregation.project(..)及其親屬定義管道階段。 但是我如何將它們放在一起並創建一個視圖? 我讀到應該有一個選項可以傳遞給createCollection(String, CollectionOptions) ,但如果有,我找不到它。

那么有沒有辦法在 spring-data-mongodb 中創建一個視圖而不訴諸mongoTemplate.executeCommand(..)

還沒有 - 請按照PR#4142進行更新。 這將允許您使用模板 API 以及聚合框架來創建視圖。

template.createView("firstYears", Student.class, match(where("year").is(1)));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM