mirror of https://github.com/buster-so/buster.git
Remove a few any types from database
This commit is contained in:
parent
9637fbad86
commit
1bf8418ab8
10
biome.json
10
biome.json
|
@ -131,16 +131,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"include": ["packages/database/**/*.ts"],
|
||||
"linter": {
|
||||
"rules": {
|
||||
"suspicious": {
|
||||
"noExplicitAny": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"include": ["**/*.js"],
|
||||
"linter": {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"useImportType": "off"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "off"
|
||||
"noExplicitAny": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,22 +199,17 @@ export async function updateChat(
|
|||
throw new Error(`Chat not found or has been deleted: ${chatId}`);
|
||||
}
|
||||
|
||||
// Build update object with only provided fields
|
||||
const updateData: Partial<UpdateableChatFields> & { updatedAt: string } = {
|
||||
// Build update object with only provided fields, filtering out protected fields
|
||||
const updateData = {
|
||||
updatedAt: new Date().toISOString(),
|
||||
...Object.fromEntries(
|
||||
Object.entries(fields).filter(
|
||||
([key, value]) =>
|
||||
value !== undefined && key !== 'id' && key !== 'createdAt' && key !== 'deletedAt'
|
||||
)
|
||||
),
|
||||
};
|
||||
|
||||
// Only add fields that are actually provided (not undefined)
|
||||
for (const [key, value] of Object.entries(fields)) {
|
||||
if (value !== undefined && key !== 'id' && key !== 'createdAt' && key !== 'deletedAt') {
|
||||
updateData[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// If updatedAt was explicitly provided, use that instead
|
||||
if ('updatedAt' in fields && fields.updatedAt !== undefined) {
|
||||
updateData.updatedAt = fields.updatedAt;
|
||||
}
|
||||
|
||||
await db
|
||||
.update(chats)
|
||||
|
|
Loading…
Reference in New Issue