TIL 24. 01. 26

const getPrevAndNextPost = async (id: string) => {
  const getPrevPost = supabase
    .from('mung_stagram')
    .select('id')
    .lt('id', id)
    .order('id', { ascending: false })
    .limit(1)
    .single();
  const getNextPost = supabase.from('mung_stagram').select('id').gt('id', id).limit(1).single();

  const response = await Promise.all([getPrevPost, getNextPost]);
  const [prev, next] = response.map((res) => res.data?.id);
  return { prev, next };
};

카테고리:

업데이트:

댓글남기기