@@ -8,18 +8,18 @@ import {
88} from 'firebase/firestore' ;
99import { db } from '@/lib/firebase' ;
1010
11- export type PostData = {
11+ export type TilData = {
1212 title : string ;
1313 content : string ;
1414 createdAt : Timestamp | null ;
1515 updatedAt : Timestamp | null ;
1616} ;
1717
18- export type Post = PostData & { id : string } ;
18+ export type Til = TilData & { id : string } ;
1919
20- export async function createPost ( uid : string , content : string , title : string ) {
21- const postsCol = collection ( db , 'users' , uid , 'posts ' ) ;
22- const docRef = await addDoc ( postsCol , {
20+ export async function createTil ( uid : string , content : string , title : string ) {
21+ const tilsCol = collection ( db , 'users' , uid , 'tils ' ) ;
22+ const docRef = await addDoc ( tilsCol , {
2323 title : title ,
2424 content,
2525 createdAt : serverTimestamp ( ) ,
@@ -33,7 +33,7 @@ function isRecord(v: unknown): v is Record<string, unknown> {
3333 return typeof v === 'object' && v !== null ;
3434}
3535
36- function parsePostData ( raw : unknown ) : PostData | null {
36+ function parseTilData ( raw : unknown ) : TilData | null {
3737 if ( ! isRecord ( raw ) ) return null ;
3838
3939 const content = raw . content ;
@@ -49,20 +49,20 @@ function parsePostData(raw: unknown): PostData | null {
4949 return { title, content, createdAt, updatedAt } ;
5050}
5151
52- export async function fetchMyPost (
52+ export async function fetchMyTil (
5353 uid : string | null | undefined ,
54- postId : string | null | undefined
55- ) : Promise < Post | null > {
56- // 여기서 uid/postId 실물 확인
57- console . log ( '[fetchMyPost] path =' , { uid, postId } ) ;
54+ tilId : string | null | undefined
55+ ) : Promise < Til | null > {
56+ // 여기서 uid/tilId 실물 확인
57+ console . log ( '[fetchMyPost] path =' , { uid, tilId } ) ;
5858
59- if ( ! uid || ! postId ) return null ;
59+ if ( ! uid || ! tilId ) return null ;
6060
61- const ref = doc ( db , 'users' , uid , 'posts ' , postId ) ;
61+ const ref = doc ( db , 'users' , uid , 'tils ' , tilId ) ;
6262 const snap = await getDoc ( ref ) ;
6363 if ( ! snap . exists ( ) ) return null ;
6464
65- const parsed = parsePostData ( snap . data ( ) ) ;
65+ const parsed = parseTilData ( snap . data ( ) ) ;
6666 if ( ! parsed ) return null ;
6767
6868 return { id : snap . id , ...parsed } ;
0 commit comments