Perform simple and compound queries in Cloud Firestore

 FirebaseFirestore db = FirebaseFirestore.getInstance();

insert

private void insertDummies(){
        User user  = User.builder().username("ssar").password("1234").email("[email protected]").build();
        CollectionReference posts = db.collection("posts");

        for (int i=2; i<11; i++){
            Map<String, Object> post = new HashMap<>();
            post.put("title", "title"+i);
            post.put("content", "content"+i);
            post.put("user", user);
            posts.document().set(post); // document 안에 아무것도 안넣어주면 자동생성 -> id
        }
    }

Untitled

읽어온 값 객체로 만들기

Post post = document.toObject(Post.class);