I work with MongoDB. I created a class and put it in the database, but when I return, I don't get the id
field (I get everything else, except the id itself). How do i get it? Here is the class:
public class Phonebook { @Id private String id; private String date; @Indexed(unique = true) @Field private String numer; private String name; private String info; public Phonebook () {} public Phonebook(String id, String date, String numer, String name, String info) { this.id = id; this.date = date; this.numer = numer; this.name = name; this.info = info; }
I create a repository:
public interface PhonebookRepository extends MongoRepository<Phonebook, String> { Phonebook findByNumer(String numer); Phonebook deleteByNumer(String numer); }
and when I request phoneBookRepository.findAll()
I get JSON. Not enough id
{ "date": "31.02.2019", "numer": "06612391", "name": "Lilit", "info": "Beauty girl" }