Merge pull request 'fix: TypeScript error in import route - cast item to access id' (#6) from develop into main
Some checks failed
Personal/recall/pipeline/head There was a failure building this commit

Reviewed-on: #6
This commit was merged in pull request #6.
This commit is contained in:
2026-03-24 02:05:45 +00:00

View File

@@ -105,21 +105,22 @@ export async function POST(req: NextRequest) {
const createdAt = parseDate((item as { createdAt?: string }).createdAt)
const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt)
const itemWithId = item as { id?: string }
if (item.id) {
const existing = await tx.note.findUnique({ where: { id: item.id } })
if (itemWithId.id) {
const existing = await tx.note.findUnique({ where: { id: itemWithId.id } })
if (existing) {
await tx.note.update({
where: { id: item.id },
where: { id: itemWithId.id },
data: { ...noteData, createdAt, updatedAt },
})
await tx.noteTag.deleteMany({ where: { noteId: item.id } })
await tx.noteTag.deleteMany({ where: { noteId: itemWithId.id } })
processed++
} else {
await tx.note.create({
data: {
...noteData,
id: item.id,
id: itemWithId.id,
createdAt,
updatedAt,
creationSource: 'import',
@@ -150,8 +151,8 @@ export async function POST(req: NextRequest) {
processed++
}
const noteId = item.id
? (await tx.note.findUnique({ where: { id: item.id } }))?.id
const noteId = itemWithId.id
? (await tx.note.findUnique({ where: { id: itemWithId.id } }))?.id
: (await tx.note.findFirst({ where: { title: item.title } }))?.id
if (noteId && tags.length > 0) {