Fakultas Ilmu Komputer UI

getEcosystem.ts 442 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import firebase from "firebase";
import { getEnv } from "../../../helpers/getEnv";
import { IEcosystem } from "../../../types/firestore/ecosystems";

export const getEcosystem = async (
  ecosystemId: string
): Promise<IEcosystem> => {
  const db = firebase.firestore();

  const doc = await db
    .collection("ecosystems_" + getEnv())
    .doc(ecosystemId)
    .get();

  return {
    id: doc.id,
    ...(doc.data() as IEcosystem),
  };
};