objection
Advanced tools
Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5
@@ -30,2 +30,3 @@ 'use strict'; | ||
const { raw } = require('./queryBuilder/RawBuilder'); | ||
const { fn } = require('./queryBuilder/FunctionBuilder'); | ||
@@ -86,2 +87,3 @@ const { inherit } = require('../lib/utils/classUtils'); | ||
raw, | ||
fn, | ||
@@ -88,0 +90,0 @@ get lit() { |
@@ -65,20 +65,20 @@ 'use strict'; | ||
function raw() { | ||
let sql = arguments[0]; | ||
let args = null; | ||
function normalizeRawArgs(argsIn) { | ||
const [sql, ...restArgs] = argsIn; | ||
if (arguments.length === 2 && Array.isArray(arguments[1])) { | ||
args = new Array(arguments[1].length); | ||
for (let i = 0, l = args.length; i < l; ++i) { | ||
args[i] = arguments[1][i]; | ||
} | ||
if (restArgs.length === 1 && Array.isArray(restArgs[0])) { | ||
return { | ||
sql, | ||
args: restArgs[0] | ||
}; | ||
} else { | ||
args = new Array(arguments.length - 1); | ||
for (let i = 1, l = arguments.length; i < l; ++i) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
return { | ||
sql, | ||
args: restArgs | ||
}; | ||
} | ||
} | ||
function raw(...argsIn) { | ||
const { sql, args } = normalizeRawArgs(argsIn); | ||
return new RawBuilder(sql, args); | ||
@@ -89,3 +89,4 @@ } | ||
RawBuilder, | ||
normalizeRawArgs, | ||
raw | ||
}; |
{ | ||
"name": "objection", | ||
"version": "2.0.0-alpha.4", | ||
"version": "2.0.0-alpha.5", | ||
"description": "An SQL-friendly ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/objection.js", |
@@ -27,2 +27,3 @@ /// <reference types="node" /> | ||
const ref: ReferenceFunction; | ||
const fn: FunctionFunction; | ||
@@ -63,2 +64,11 @@ const compose: ComposeFunction; | ||
export interface FunctionBuilder extends Castable {} | ||
export interface FunctionFunction { | ||
(functionName: string, ...arguments: any[]): FunctionBuilder; | ||
now(precision: number): FunctionBuilder; | ||
coalesce(...arguments: any[]): FunctionBuilder; | ||
concat(...arguments: any[]): FunctionBuilder; | ||
} | ||
export interface ComposeFunction { | ||
@@ -171,3 +181,3 @@ (...plugins: Plugin[]): Plugin; | ||
: (T[K] | NonPrimitiveValue); | ||
} | ||
}; | ||
@@ -1399,2 +1409,3 @@ /** | ||
static raw: RawFunction; | ||
static ref: ReferenceFunction; | ||
static fn: knex.FunctionHelper; | ||
@@ -1401,0 +1412,0 @@ |
614620
176
19160