Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL KI Ganjil 2021 2022
Clicks - Ecosystem Business
clicks-frontend
Commits
7dde4a64
Commit
7dde4a64
authored
Dec 04, 2021
by
Ahmad Izzudin Alifyandra
Browse files
Merge branch 'forum-fetch-function' into 'master'
feat: Forum fetch function See merge request
!157
parents
1ea53e4b
611fb411
Pipeline
#88954
passed with stage
in 10 minutes and 18 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/service/firestore/forum/fetchCommentsByPostId.ts
0 → 100644
View file @
7dde4a64
import
firebase
from
"
firebase
"
;
import
{
getEnv
}
from
"
../../../helpers/getEnv
"
;
import
{
IThreadComment
}
from
"
../../../types/firestore/threadComment
"
;
export
const
fetchCommentsByPostId
=
async
(
postId
:
string
):
Promise
<
IThreadComment
[]
>
=>
{
const
db
=
firebase
.
firestore
();
const
query
=
db
.
collection
(
"
thread_comments_
"
+
getEnv
())
.
where
(
"
threadId
"
,
"
==
"
,
postId
)
.
orderBy
(
"
timestamp
"
,
"
desc
"
);
const
snap
=
await
query
.
get
();
const
comments
:
IThreadComment
[]
=
[];
snap
.
docs
.
forEach
((
doc
)
=>
{
const
data
:
IThreadComment
=
{
...(
doc
.
data
()
as
IThreadComment
),
id
:
doc
.
id
,
};
comments
.
push
(
data
);
});
return
comments
;
};
src/service/firestore/forum/fetchPost.ts
0 → 100644
View file @
7dde4a64
import
firebase
from
"
firebase
"
;
import
{
getEnv
}
from
"
../../../helpers/getEnv
"
;
import
{
IThread
}
from
"
../../../types/firestore/thread
"
;
export
const
fetchPost
=
async
(
postId
:
string
)
=>
{
const
db
=
firebase
.
firestore
();
const
query
=
db
.
collection
(
"
threads_
"
+
getEnv
()).
doc
(
postId
);
const
snap
=
await
query
.
get
();
const
post
=
{
...(
snap
.
data
()
as
IThread
),
id
:
snap
.
id
};
return
post
;
};
src/service/firestore/forum/fetchPostsByEcosystemId.ts
0 → 100644
View file @
7dde4a64
import
firebase
from
"
firebase
"
;
import
{
getEnv
}
from
"
../../../helpers/getEnv
"
;
import
{
IThread
}
from
"
../../../types/firestore/thread
"
;
export
const
fetchPostsByEcosystemId
=
async
(
ecosystemId
:
string
):
Promise
<
IThread
[]
>
=>
{
const
db
=
firebase
.
firestore
();
const
query
=
db
.
collection
(
"
threads_
"
+
getEnv
())
.
where
(
"
ecosystemId
"
,
"
==
"
,
ecosystemId
)
.
orderBy
(
"
timestamp
"
,
"
desc
"
);
const
snap
=
await
query
.
get
();
const
posts
:
IThread
[]
=
[];
snap
.
docs
.
forEach
((
doc
)
=>
{
const
data
:
IThread
=
{
...(
doc
.
data
()
as
IThread
),
id
:
doc
.
id
};
posts
.
push
(
data
);
});
return
posts
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment