Make bigint into number instead of string

This commit is contained in:
arttu
2024-06-06 18:18:32 +03:00
parent 81581e447f
commit eaba5b1671
2 changed files with 11 additions and 10 deletions
+10 -9
View File
@@ -78,15 +78,16 @@ export const fixEditedLocality = (editedLocality: EditDataType<LocalityDetailsTy
lau_date: new Date(lau.lau_date!),
}))
}
if (editedLocality.now_ls) {
editedLocality.now_ls = editedLocality.now_ls.map(now_ls => ({
...now_ls,
com_species: {
...now_ls.com_species,
body_mass: now_ls.com_species.body_mass, // TODO FIX ? null : BigInt(now_ls.com_species.body_mass!),
},
}))
}
// TODO: see if we have to turn these into bigint or if writing number to db is ok.
// if (editedLocality.now_ls) {
// editedLocality.now_ls = editedLocality.now_ls.map(now_ls => ({
// ...now_ls,
// com_species: {
// ...now_ls.com_species,
// body_mass: now_ls.com_species.body_mass,
// },
// }))
// }
return editedLocality
}
+1 -1
View File
@@ -2,4 +2,4 @@ export const sleep = async (ms: number) => new Promise(resolve => setTimeout(res
export const fixBigInt = (obj: object | null) =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
obj === null ? null : JSON.stringify(obj, (_key, value) => (typeof value === 'bigint' ? value.toString() : value))
obj === null ? null : JSON.stringify(obj, (_key, value) => (typeof value === 'bigint' ? Number(value) : value))