refactor: return data as data field

This commit is contained in:
Thomas Bishop 2025-07-23 13:10:19 +01:00
parent dbd63cfc42
commit 5d70e9a23f
2 changed files with 21 additions and 21 deletions

View file

@ -21,7 +21,7 @@ export default class EntriesService {
return { return {
count: sliced.length, count: sliced.length,
entries: sliced, data: sliced,
} }
} }
@ -29,7 +29,7 @@ export default class EntriesService {
const entries = this.database.prepare(GET_ENTRIES_FOR_TAG).all(tag) const entries = this.database.prepare(GET_ENTRIES_FOR_TAG).all(tag)
return { return {
count: entries.length, count: entries.length,
entries: data:
sort === "date" sort === "date"
? this._sortByDate(entries) ? this._sortByDate(entries)
: this._sortByTitle(entries, "entry_title"), : this._sortByTitle(entries, "entry_title"),

View file

@ -11,14 +11,14 @@ export default class TagsService {
const tags = this.database.prepare(GET_ALL_TAGS).all() const tags = this.database.prepare(GET_ALL_TAGS).all()
const sorted = this._sortTags(tags, "name") const sorted = this._sortTags(tags, "name")
const list = sorted.flatMap((tag) => tag.name) const list = sorted.flatMap((tag) => tag.name)
return { count: tags.length, tags: list } return { count: tags.length, data: list }
} }
getTagsForEntry = (entryTitle) => { getTagsForEntry = (entryTitle) => {
const tags = this.database.prepare(GET_TAGS_FOR_ENTRY).all(entryTitle) const tags = this.database.prepare(GET_TAGS_FOR_ENTRY).all(entryTitle)
const sorted = this._sortTags(tags, "tag_name") const sorted = this._sortTags(tags, "tag_name")
const list = sorted.flatMap((tag) => tag.tag_name) const list = sorted.flatMap((tag) => tag.tag_name)
return { count: tags.length, tags: list } return { count: tags.length, data: list }
} }
_sortTags = (tags, fieldName) => { _sortTags = (tags, fieldName) => {