reduce sql error

This commit is contained in:
Hongbo Wu
2024-02-06 16:23:16 +08:00
parent 7e022e3294
commit efd8119e02
3 changed files with 9 additions and 7 deletions

View File

@ -180,7 +180,7 @@ export const findHighlightById = async (
return authTrx(
async (tx) => {
const highlightRepo = tx.withRepository(highlightRepository)
return highlightRepo.findOneByOrFail({
return highlightRepo.findOneBy({
id: highlightId,
})
},

View File

@ -187,10 +187,12 @@ export const saveLabelsInHighlight = async (
)
const highlight = await findHighlightById(highlightId, userId)
// update labels in library item
await bulkEnqueueUpdateLabels([
{ libraryItemId: highlight.libraryItemId, userId },
])
if (highlight) {
// update labels in library item
await bulkEnqueueUpdateLabels([
{ libraryItemId: highlight.libraryItemId, userId },
])
}
}
export const findLabelsByIds = async (

View File

@ -295,8 +295,8 @@ describe('Highlights API', () => {
expect(res.body.data.mergeHighlight.highlight.id).to.eq(newHighlightId)
const highlight = await findHighlightById(newHighlightId, user.id)
expect(highlight.labels).to.have.lengthOf(1)
expect(highlight.labels?.[0]?.name).to.eq(labelName)
expect(highlight?.labels).to.have.lengthOf(1)
expect(highlight?.labels?.[0]?.name).to.eq(labelName)
highlightId = newHighlightId
})