# User

Crie a entidade User. Diferente de quando usamos os outros bancos, ela não terá @Entity e sim @Document.

Serão anottations advindas do MongoDB.

```java
@Document(collection = "users") 
@Getter 
@Setter 
@AllArgsConstructor
@NoArgsConstructor 
public class User {
    @Id
    private String id;
    private String name;
    private String email;
    
    public User(String id, String name, String email) {
        this.id = id;
        this.name = name;
        this.email = email;
    }
    
    //Quando formos buscar um Usuário, não é para carregar os seus posts. 
    //Só carregamos os posts se chamarmos eles.
    @DBRef(lazy = true).
    @Setter(AccessLevel.NONE)
    public List<Post> posts = new ArrayList<>();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://olavo-moreira.gitbook.io/studies/workshop-mongodb/entidades-e-mapeamento/user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
