Reputation: 41
How to create view in mongodb using spring data mongodb? Thanks
Upvotes: 4
Views: 1627
Reputation: 76
You can inject bean of type org.springframework.data.mongodb.core.MongoTemplate where you need it and use one of its methods executeCommand, for example executeCommand(String jsonCommand) in folowing manner:
mongoTemplate.executeCommand("{ create: <view>, viewOn: <source>, pipeline: <pipeline> }");
Upvotes: 3