Add an SQL DB abstraction layer

Because what self-respecting Enterprise(R) project doesn't have
one of those?
This commit is contained in:
Tau
2019-11-06 17:28:30 -05:00
parent 2ccd9dc382
commit 3e6b4f4798
32 changed files with 440 additions and 541 deletions
+14
View File
@@ -0,0 +1,14 @@
import { randomBytes } from "crypto";
export function generateId(): bigint {
const buf = randomBytes(8);
buf[0] &= 0x7f; // Force number to be non-negative
// Let's not depend on Node v12 for the sake of 3 LoC just yet.
const hi = buf.readUInt32BE(0);
const lo = buf.readUInt32BE(4);
return (BigInt(hi) << 32n) | BigInt(lo);
}