2

I can retrieve the distinct values for a field using mongoDB query as,

db.context.distinct("context_name")

which results ["Restaurant", "School"]

My Mongo collection name is Context and a document looks like,

{
    "_id" : ObjectId("57ca8a45cadee6167c4d92ba"),
    "_class" : "com.something.webappmongo.domain.Context",
    "context_name" : "Restaurant"
}

Now I want to get result using this query from Spring framework (Spring Boot 1.4.0). I was using Jhipster.

How to do it in repository interface and resource class?

1 Answer 1

2

Create a Repository method "findDistinctBy[field]"

Sign up to request clarification or add additional context in comments.

1 Comment

You need to be a lot more verbose than that. What did you try, what does your code look like, what's written in the logs? Nobody can help you based on "It didn't work".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.