MCPcopy Create free account
hub / github.com/dev-mastery/comments-api / findAll

Function findAll

src/data-access/comments-db.js:14–22  ·  view source on GitHub ↗
({ publishedOnly = true } = {})

Source from the content-addressed store, hash-verified

12 update
13 })
14 async function findAll ({ publishedOnly = true } = {}) {
15 const db = await makeDb()
16 const query = publishedOnly ? { published: true } : {}
17 const result = await db.collection('comments').find(query)
18 return (await result.toArray()).map(({ _id: id, ...found }) => ({
19 id,
20 ...found
21 }))
22 }
23 async function findById ({ id: _id }) {
24 const db = await makeDb()
25 const result = await db.collection('comments').find({ _id })

Callers

nothing calls this directly

Calls 1

makeDbFunction · 0.70

Tested by

no test coverage detected