@clickup/ent-framework
Version:
A PostgreSQL graph-database-alike library with microsharding and row-level security
28 lines • 1.23 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.BigIntArrayType = BigIntArrayType;
const pg_1 = require("pg");
/**
* It is in pg-types/lib/textParsers.js (1016::regtype is "bigint[]"), just not
* exported to TS types.
*/
const BIGINT_ARRAY_OID = 1016;
/**
* An array of IDs. Notice that:
* 1. Node-postgres natively supports this type on read path, but on write path,
* we have to stringify by ourselves.
* 2. GIN index doesn't support NULL, because PG's "&&" operator (intersection
* check) doesn't work with NULLs. But we still allow NULLs in BigIntArrayType,
* because to query such values, we can use a separate partial index.
*/
function BigIntArrayType() {
return {
dbValueToJs: (dbValue) => dbValue,
// PG's representation: '{123,NULL,NULL,223}'. Notice that the unquoted NULL
// must be of a capital case to denote a null value, otherwise it's treated
// as a 4-char string "null". This is a part of the protocol.
stringify: (jsValue) => "{" + jsValue.map((v) => v ?? "NULL").join(",") + "}",
parse: (str) => pg_1.types.getTypeParser(BIGINT_ARRAY_OID)(str),
};
}
//# sourceMappingURL=BigIntArrayType.js.map
;