MCPcopy Index your code
hub / github.com/simstudioai/sim / getDocumentMetadataByIds

Function getDocumentMetadataByIds

apps/sim/app/api/knowledge/search/utils.ts:19–49  ·  view source on GitHub ↗
(
  documentIds: string[]
)

Source from the content-addressed store, hash-verified

17 * indicate the document is no longer visible and should be skipped.
18 */
19export async function getDocumentMetadataByIds(
20 documentIds: string[]
21): Promise<Record<string, DocumentMetadata>> {
22 if (documentIds.length === 0) {
23 return {}
24 }
25
26 const uniqueIds = [...new Set(documentIds)]
27 const documents = await db
28 .select({
29 id: document.id,
30 filename: document.filename,
31 sourceUrl: document.sourceUrl,
32 })
33 .from(document)
34 .where(
35 and(
36 inArray(document.id, uniqueIds),
37 eq(document.userExcluded, false),
38 isNull(document.archivedAt),
39 isNull(document.deletedAt)
40 )
41 )
42
43 const map: Record<string, DocumentMetadata> = {}
44 documents.forEach((doc) => {
45 map[doc.id] = { filename: doc.filename, sourceUrl: doc.sourceUrl ?? null }
46 })
47
48 return map
49}
50
51export interface SearchResult {
52 id: string

Callers 3

route.tsFile · 0.90
route.tsFile · 0.90
utils.test.tsFile · 0.85

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected