refql
Version:
A Node.js and Deno library for composing and running SQL queries.
32 lines (31 loc) • 1.08 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const consts_1 = require("../common/consts");
const Raw_1 = __importDefault(require("../SQLTag/Raw"));
const sql_1 = require("../SQLTag/sql");
const Operation_1 = require("./Operation");
const type = "refql/IsNull";
const prototype = Object.assign({}, Operation_1.operationPrototype, {
constructor: IsNull,
[consts_1.refqlType]: type,
interpret
});
function IsNull(notIsNull = false) {
let isNull = Object.create(prototype);
isNull.notIsNull = notIsNull;
return isNull;
}
function interpret(col, displayAnd) {
const { notIsNull } = this;
const equality = notIsNull ? "is not null" : "is null";
return (0, sql_1.sqlX) `
${(0, Raw_1.default)(displayAnd ? "and " : "")}${col} ${(0, Raw_1.default)(equality)}
`;
}
IsNull.isNull = function (x) {
return x != null && x[consts_1.refqlType] === type;
};
exports.default = IsNull;
;