You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
907 B
JavaScript
29 lines
907 B
JavaScript
"use strict";
|
|
|
|
const { validateArguments } = require("@validatem/core");
|
|
const required = require("@validatem/required");
|
|
const either = require("@validatem/either");
|
|
|
|
const node = require("../ast-node");
|
|
|
|
module.exports = function (operations) {
|
|
const isObjectType = require("../validators/operations/is-object-type")(operations);
|
|
const isExpression = require("../validators/operations/is-expression")(operations);
|
|
const isWhereObject = require("../validators/operations/is-where-object")(operations);
|
|
|
|
return function where(_predicates) {
|
|
let [ predicates ] = validateArguments(arguments, {
|
|
predicates: [ required, either([
|
|
[ isObjectType("sqlExpression") ],
|
|
[ isExpression ], // FIXME: Make sure to document that this is what is to be used instead of two-argument WHERE syntax
|
|
[ isWhereObject ]
|
|
])]
|
|
});
|
|
|
|
return node({
|
|
type: "where",
|
|
expression: predicates
|
|
});
|
|
};
|
|
};
|