Skip to content

Commit 606e697

Browse files
committed
chore: improve uint256 database type impl
1 parent 19867a3 commit 606e697

File tree

1 file changed

+10
-8
lines changed
  • packages/fasset-indexer-core/src/orm/custom

1 file changed

+10
-8
lines changed

packages/fasset-indexer-core/src/orm/custom/uint.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import { Type } from '@mikro-orm/core'
22

33

4-
export class uint256 extends Type<bigint | null | undefined, string | null | undefined> {
4+
type Nullable<T> = T | null | undefined
55

6-
convertToDatabaseValue(value: bigint | null | undefined): string | null {
6+
export class uint256 extends Type<Nullable<bigint>, Nullable<string>> {
7+
8+
convertToDatabaseValue(value: Nullable<bigint>): string | null {
79
if (value === null || value === undefined) {
8-
return null;
10+
return null
911
}
10-
return value.toString();
12+
return value.toString()
1113
}
1214

13-
convertToJSValue(value: string | null | undefined): bigint | null {
15+
convertToJSValue(value: Nullable<string>): bigint | null {
1416
if (value === null || value === undefined) {
15-
return null;
17+
return null
1618
}
17-
return BigInt(value);
19+
return BigInt(value)
1820
}
1921

2022
getColumnType() {
21-
return `NUMERIC(78)`; // or DECIMAL(78), depending on your DB
23+
return `NUMERIC(78)`
2224
}
2325
}
2426

0 commit comments

Comments
 (0)