Skip to content

Commit

Permalink
feat: Add lastUpdated attribute to search index
Browse files Browse the repository at this point in the history
This might be useful to know when a search index had been updated
  • Loading branch information
paultranvan committed Oct 21, 2024
1 parent a9cebf0 commit 1aa6018
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/search/SearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class SearchEngine {

this.searchIndexes[doctype] = {
index,
lastSeq: info?.update_seq
lastSeq: info?.update_seq,
lastUpdated: new Date().toISOString()
}
return this.searchIndexes[doctype]
}
Expand All @@ -204,6 +205,7 @@ class SearchEngine {
}

searchIndex.lastSeq = changes.last_seq
searchIndex.lastUpdated = new Date().toISOString()
return searchIndex
}

Expand Down
3 changes: 2 additions & 1 deletion src/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export interface SearchResult {

export interface SearchIndex {
index: FlexSearch.Document<CozyDoc, true>
lastSeq: number
lastSeq: number | null
lastUpdated: string
}

export type SearchIndexes = {
Expand Down

0 comments on commit 1aa6018

Please sign in to comment.