MCPcopy Index your code
hub / github.com/dev-mastery/comments-api / findByPostId

Function findByPostId

src/data-access/comments-db.js:33–44  ·  view source on GitHub ↗
({ postId, omitReplies = true })

Source from the content-addressed store, hash-verified

31 return { id, ...info }
32 }
33 async function findByPostId ({ postId, omitReplies = true }) {
34 const db = await makeDb()
35 const query = { postId: postId }
36 if (omitReplies) {
37 query.replyToId = null
38 }
39 const result = await db.collection('comments').find(query)
40 return (await result.toArray()).map(({ _id: id, ...found }) => ({
41 id,
42 ...found
43 }))
44 }
45 async function findReplies ({ commentId, publishedOnly = true }) {
46 const db = await makeDb()
47 const query = publishedOnly

Callers

nothing calls this directly

Calls 1

makeDbFunction · 0.70

Tested by

no test coverage detected