import { Timestamp } from "@firebase/firestore";
import를 위와 같이 하고
const handleSubmit = async (e) => {
e.preventDefault();
const ref = collection(db, "todos"); //db config 추가하기
await addDoc(ref, {
title: newTodo, //입력할 내용을 객체형식으로 넣으면됨
uid: user.uid,
createdAt: Timestamp.fromDate(new Date()), //날짜 추가
}); //추가할 때 까지 대기 await
createAt으로 추가하면됨
참고
https://stackoverflow.com/questions/69519447/how-to-get-server-timestamp-from-firebase-v9
How to get server Timestamp from firebase v9?
Please, I need your help to get the server timestamp from Firebase version 9. I've tried to follow the same approach as for Firebase v8 : firebase.firestore.FieldValue.serverTimeStamp() but didn't ...
stackoverflow.com
'FRONTEND > React' 카테고리의 다른 글
[Nwitter-Fire] SNS 프로젝트 시작하기 /styled 컴포넌트/ firebase9 유저인증 (1) | 2023.12.08 |
---|---|
[슈퍼챗] firebase9 활용한 슈퍼챗 만들기 (2) | 2023.12.07 |
[파이어 9] 초기화 , 파이어 베이스 9버전 사용으로 할 일 관리 앱 만들기 (1) | 2023.12.06 |
[마이머니앱] 정렬 추가하기 (0) | 2023.12.05 |
[마이머니앱] 보안 (0) | 2023.12.05 |