Reputation: 19938
Let say I have a simple mongoRepository below:
public interface LettersRepository extends MongoRepository<Posts, String> {
}
I'm connecting to Mongolab. The collection name on Mongolab has to be 'letters' for the autowiring to work.
Now, I don't want to call my collection on Mongolab 'letters'. I want to call it 'mails'.
How do I use annotations to configure that the autowiring will point to the 'mails' collection instead?
I tried the annotation @Repository(value="mails")
above the interface but it does not work.
Upvotes: 0
Views: 314
Reputation: 7911
The mapping to Mongo collections depends on your domain object, not the repository. If you want your Posts
class to be stored in the collection mails
, annotate it with @Document
:
@Document(collection = "mails")
public class Posts {
}
See the Mapping chapter in the documentation for details.
Upvotes: 2