Skip to content

Commit

Permalink
Documented scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
grassick committed Nov 4, 2020
1 parent 80343fb commit c6497ad
Show file tree
Hide file tree
Showing 7 changed files with 4,348 additions and 7,319 deletions.
4 changes: 1 addition & 3 deletions lib/JsonqlCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ _ = require('lodash');
SqlFragment = require('./SqlFragment');
QueryOptimizer = require('./QueryOptimizer'); // Compiles jsonql to sql

module.exports = JsonqlCompiler =
/*#__PURE__*/
function () {
module.exports = JsonqlCompiler = /*#__PURE__*/function () {
function JsonqlCompiler(schemaMap) {
var optimizeQueries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
(0, _classCallCheck2["default"])(this, JsonqlCompiler);
Expand Down
4 changes: 1 addition & 3 deletions lib/QueryOptimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ See the tests for examples of all three re-writings. The speed difference is 100
*/

module.exports = QueryOptimizer =
/*#__PURE__*/
function () {
module.exports = QueryOptimizer = /*#__PURE__*/function () {
function QueryOptimizer() {
(0, _classCallCheck2["default"])(this, QueryOptimizer);
// Extract all jsonql field expressions from a jsonql fragment
Expand Down
4 changes: 1 addition & 3 deletions lib/SchemaMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
var SchemaMap, SqlFragment;
SqlFragment = require('./SqlFragment'); // Maps tables and columns to a secure sql fragment. Base class is simple passthrough

module.exports = SchemaMap =
/*#__PURE__*/
function () {
module.exports = SchemaMap = /*#__PURE__*/function () {
function SchemaMap() {
(0, _classCallCheck2["default"])(this, SchemaMap);
}
Expand Down
4 changes: 1 addition & 3 deletions lib/SqlFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ var SqlFragment, _, pgescape;
_ = require('lodash');
pgescape = require('pg-escape'); // Fragment of SQL that has sql (text) and params (array)

module.exports = SqlFragment =
/*#__PURE__*/
function () {
module.exports = SqlFragment = /*#__PURE__*/function () {
function SqlFragment(sql, params) {
(0, _classCallCheck2["default"])(this, SqlFragment);
this.sql = sql || "";
Expand Down
17 changes: 17 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,20 @@ export interface JsonQLSelect {
expr: JsonQLExpr
alias: string
}

/** Scalar subquery */
export interface JsonQLScalar {
type: "scalar",
expr: JsonQLExpr
where?: JsonQLExpr
from: JsonQLFrom

/** orderBy: array of { ordinal: (1 based) or expr: expression, direction: "asc"/"desc" (default asc), nulls: "last"/"first" (default is not set) } (optional) */
orderBy?: ({ ordinal: number, direction?: "asc" | "desc", nulls?: "last" | "first" } | { expr: JsonQLExpr, direction?: "asc" | "desc", nulls?: "last" | "first" })[]

/** Limit number of rows */
limit?: number

/** withs: common table expressions (optional). array of { query:, alias: } */
withs?: { query: JsonQLQuery, alias: string }[]
}
Loading

0 comments on commit c6497ad

Please sign in to comment.