drizzle-orm
Version:
Drizzle ORM package for SQL databases
104 lines • 3.17 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var point_exports = {};
__export(point_exports, {
PgPointObject: () => PgPointObject,
PgPointObjectBuilder: () => PgPointObjectBuilder,
PgPointTuple: () => PgPointTuple,
PgPointTupleBuilder: () => PgPointTupleBuilder,
point: () => point
});
module.exports = __toCommonJS(point_exports);
var import_entity = require("../../entity.cjs");
var import_utils = require("../../utils.cjs");
var import_common = require("./common.cjs");
class PgPointTupleBuilder extends import_common.PgColumnBuilder {
static [import_entity.entityKind] = "PgPointTupleBuilder";
constructor(name) {
super(name, "array", "PgPointTuple");
}
/** @internal */
build(table) {
return new PgPointTuple(
table,
this.config
);
}
}
class PgPointTuple extends import_common.PgColumn {
static [import_entity.entityKind] = "PgPointTuple";
getSQLType() {
return "point";
}
mapFromDriverValue(value) {
if (typeof value === "string") {
const [x, y] = value.slice(1, -1).split(",");
return [Number.parseFloat(x), Number.parseFloat(y)];
}
return [value.x, value.y];
}
mapToDriverValue(value) {
return `(${value[0]},${value[1]})`;
}
}
class PgPointObjectBuilder extends import_common.PgColumnBuilder {
static [import_entity.entityKind] = "PgPointObjectBuilder";
constructor(name) {
super(name, "json", "PgPointObject");
}
/** @internal */
build(table) {
return new PgPointObject(
table,
this.config
);
}
}
class PgPointObject extends import_common.PgColumn {
static [import_entity.entityKind] = "PgPointObject";
getSQLType() {
return "point";
}
mapFromDriverValue(value) {
if (typeof value === "string") {
const [x, y] = value.slice(1, -1).split(",");
return { x: Number.parseFloat(x), y: Number.parseFloat(y) };
}
return value;
}
mapToDriverValue(value) {
return `(${value.x},${value.y})`;
}
}
function point(a, b) {
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
if (!config?.mode || config.mode === "tuple") {
return new PgPointTupleBuilder(name);
}
return new PgPointObjectBuilder(name);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PgPointObject,
PgPointObjectBuilder,
PgPointTuple,
PgPointTupleBuilder,
point
});
//# sourceMappingURL=point.cjs.map