Perform simple and compound queries in Cloud Firestore
FirebaseFirestore db = FirebaseFirestore.getInstance();
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
}
}
Post post = document.toObject(Post.class);