populateAuthors() — supabase Function Reference
Architecture documentation for the populateAuthors() function in populateAuthors.ts from the supabase codebase.
Entity Profile
Relationship Graph
Source Code
apps/cms/src/collections/Posts/hooks/populateAuthors.ts lines 5–34
export const populateAuthors: CollectionAfterReadHook = async ({ doc, req: { payload } }) => {
if (doc?.authors && doc?.authors?.length > 0) {
const authorDocs: Author[] = []
for (const author of doc.authors) {
try {
const authorDoc = await payload.findByID({
id: typeof author === 'object' ? author?.id : author,
collection: 'authors',
depth: 0,
})
if (authorDoc) {
authorDocs.push(authorDoc)
}
if (authorDocs.length > 0) {
doc.populatedAuthors = authorDocs.map((authorDoc) => ({
id: authorDoc.id,
name: authorDoc.author,
}))
}
} catch {
// swallow error
}
}
}
return doc
}
Domain
Subdomains
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free