@spinajs/orm
Advanced tools
Comparing version 2.0.223 to 2.0.224
import { Container, Constructor, IContainer } from '@spinajs/di'; | ||
import { ColumnType, QueryMethod, SortOrder, WhereBoolean, SqlOperator } from './enums.js'; | ||
import { IColumnsBuilder, ICompilerOutput, ILimitBuilder, IOrderByBuilder, IQueryBuilder, IQueryLimit, ISort, IWhereBuilder, QueryContext, IJoinBuilder, IBuilderMiddleware, IWithRecursiveBuilder, ReferentialAction, IGroupByBuilder, IUpdateResult, DefaultValueBuilder, ColumnAlterationType, QueryMiddleware, IBuilder, IDeleteQueryBuilder, IUpdateQueryBuilder, IFilter, ISelectQueryBuilder } from './interfaces.js'; | ||
import { IColumnsBuilder, ICompilerOutput, ILimitBuilder, IOrderByBuilder, IQueryBuilder, IQueryLimit, ISort, IWhereBuilder, QueryContext, IJoinBuilder, IBuilderMiddleware, IWithRecursiveBuilder, ReferentialAction, IGroupByBuilder, IUpdateResult, DefaultValueBuilder, ColumnAlterationType, QueryMiddleware, IBuilder, IDeleteQueryBuilder, IUpdateQueryBuilder, ISelectQueryBuilder } from './interfaces.js'; | ||
import { ColumnStatement, IQueryStatement, RawQueryStatement, Wrap } from './statements.js'; | ||
@@ -201,3 +201,2 @@ import { ModelDataWithRelationDataSearchable, PickRelations, Unbox, WhereFunction } from './types.js'; | ||
when(condition: boolean, callback?: WhereFunction<T>, callbackElse?: WhereFunction<T>): this; | ||
filter(filters: IFilter[]): this; | ||
where(column: string | boolean | WhereFunction<T> | RawQuery | Wrap | Partial<ModelDataWithRelationDataSearchable<Unbox<T>>> | PickRelations<T>, operator?: SqlOperator | any, value?: any): this; | ||
@@ -204,0 +203,0 @@ orWhere(column: string | boolean | WhereFunction<T> | RawQuery | Wrap | Partial<ModelDataWithRelationDataSearchable<Unbox<T>>>, ..._args: any[]): this; |
@@ -517,48 +517,2 @@ "use strict"; | ||
} | ||
filter(filters) { | ||
filters.forEach((filter) => { | ||
switch (filter.Operator) { | ||
case 'eq': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.EQ, filter.Value); | ||
break; | ||
case 'neq': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.NOT, filter.Value); | ||
break; | ||
case 'gt': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.GT, filter.Value); | ||
break; | ||
case 'gte': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.GTE, filter.Value); | ||
break; | ||
case 'lt': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.LT, filter.Value); | ||
break; | ||
case 'lte': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.LTE, filter.Value); | ||
break; | ||
case 'like': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.LIKE, filter.Value); | ||
break; | ||
case 'in': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.IN, filter.Value); | ||
break; | ||
case 'nin': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.NOT_IN, filter.Value); | ||
break; | ||
case 'between': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.BETWEEN, filter.Value); | ||
break; | ||
case 'isnull': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.NULL); | ||
break; | ||
case 'notnull': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.NOT_NULL); | ||
break; | ||
case 'notbetween': | ||
this.andWhere(filter.Column, enums_js_1.SqlOperator.NOT_BETWEEN, filter.Value); | ||
break; | ||
} | ||
}); | ||
return this; | ||
} | ||
where(column, operator, value) { | ||
@@ -882,2 +836,4 @@ const self = this; | ||
this._statements = this._statements.concat(stms); | ||
this._limit = builder._limit; | ||
this._sort = builder._sort; | ||
} | ||
@@ -884,0 +840,0 @@ min(column, as) { |
@@ -6,3 +6,2 @@ import { Constructor, IContainer } from '@spinajs/di'; | ||
import { Relation } from './relation-objects.js'; | ||
import { FilterableOperators } from './types.js'; | ||
export declare const MODEL_DESCTRIPTION_SYMBOL: unique symbol; | ||
@@ -57,3 +56,2 @@ export declare const MIGRATION_DESCRIPTION_SYMBOL: unique symbol; | ||
export declare function Primary(): any; | ||
export declare function Filterable(operators: FilterableOperators[]): any; | ||
/** | ||
@@ -60,0 +58,0 @@ * Marks columns as UUID. Column will be generated ad creation |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Set = exports.UniversalConverter = exports.Json = exports.DateTime = exports.HasManyToMany = exports.Historical = exports.HasMany = exports.ForwardBelongsTo = exports.BelongsTo = exports.forwardRef = exports.Recursive = exports.DiscriminationMap = exports.JunctionTable = exports.Uuid = exports.Ignore = exports.Filterable = exports.Primary = exports.Archived = exports.SoftDelete = exports.UpdatedAt = exports.CreatedAt = exports.Model = exports.Connection = exports.Migration = exports.extractDecoratorDescriptor = exports.MIGRATION_DESCRIPTION_SYMBOL = exports.MODEL_DESCTRIPTION_SYMBOL = void 0; | ||
exports.Set = exports.UniversalConverter = exports.Json = exports.DateTime = exports.HasManyToMany = exports.Historical = exports.HasMany = exports.ForwardBelongsTo = exports.BelongsTo = exports.forwardRef = exports.Recursive = exports.DiscriminationMap = exports.JunctionTable = exports.Uuid = exports.Ignore = exports.Primary = exports.Archived = exports.SoftDelete = exports.UpdatedAt = exports.CreatedAt = exports.Model = exports.Connection = exports.Migration = exports.extractDecoratorDescriptor = exports.MIGRATION_DESCRIPTION_SYMBOL = exports.MODEL_DESCTRIPTION_SYMBOL = void 0; | ||
/* eslint-disable prettier/prettier */ | ||
@@ -190,15 +190,2 @@ const converters_js_1 = require("./converters.js"); | ||
exports.Primary = Primary; | ||
function Filterable(operators) { | ||
return extractDecoratorDescriptor((model, _target, propertyKey) => { | ||
const columnDesc = model.Columns.find((c) => c.Name === propertyKey); | ||
if (!columnDesc) { | ||
// we dont want to fill all props, they will be loaded from db and mergeg with this | ||
model.Columns.push({ Name: propertyKey, Filterable: operators }); | ||
} | ||
else { | ||
columnDesc.Filterable = operators; | ||
} | ||
}, true); | ||
} | ||
exports.Filterable = Filterable; | ||
/** | ||
@@ -205,0 +192,0 @@ * Marks columns as UUID. Column will be generated ad creation |
@@ -38,3 +38,3 @@ "use strict"; | ||
} | ||
if (val.Type === interfaces_js_1.RelationType.Many) { | ||
else { | ||
if (model[val.Name]) { | ||
@@ -41,0 +41,0 @@ const v = [...model[val.Name]]; |
@@ -5,3 +5,3 @@ import { Op } from './enums.js'; | ||
import { IQueryStatement, Wrap } from './statements.js'; | ||
import { FilterableOperators, ModelData, ModelDataWithRelationData, ModelDataWithRelationDataSearchable, PartialArray, PickRelations, Unbox, WhereFunction } from './types.js'; | ||
import { ModelData, ModelDataWithRelationData, ModelDataWithRelationDataSearchable, PartialArray, PickRelations, Unbox, WhereFunction } from './types.js'; | ||
import { IOrmRelation } from './relations.js'; | ||
@@ -27,7 +27,2 @@ import { OrmDriver } from './driver.js'; | ||
} | ||
export interface IFilter { | ||
Column: string; | ||
Operator: FilterableOperators; | ||
Value: any; | ||
} | ||
export interface IRelation<R extends ModelBase<R>, O extends ModelBase<O>> extends Array<R> { | ||
@@ -542,6 +537,2 @@ TargetModelDescriptor: IModelDescriptor; | ||
/** | ||
* If set column is fitlerable by this operators | ||
*/ | ||
Filterable?: FilterableOperators[]; | ||
/** | ||
* Default column value | ||
@@ -774,3 +765,2 @@ */ | ||
clearWhere(): this; | ||
filter(filter: IFilter[]): this; | ||
} | ||
@@ -777,0 +767,0 @@ export interface IWithRecursiveBuilder { |
@@ -1,2 +0,2 @@ | ||
import { FilterableOperators, ModelData, ModelDataWithRelationData, PartialArray, PickRelations } from './types.js'; | ||
import { ModelData, ModelDataWithRelationData, PartialArray, PickRelations } from './types.js'; | ||
import { IModelDescriptor, InsertBehaviour, IUpdateResult, ISelectQueryBuilder, IWhereBuilder, QueryScope, IHistoricalModel, IModelBase, IRelationDescriptor } from './interfaces.js'; | ||
@@ -58,13 +58,2 @@ import { WhereFunction } from './types.js'; | ||
/** | ||
* Get list of filterable columns for this model and allowed operators | ||
*/ | ||
static filterColumns(): { | ||
column: string; | ||
operators: FilterableOperators[]; | ||
}[]; | ||
/** | ||
* Gets filter columns schema for validation | ||
*/ | ||
static filterSchema(): any; | ||
/** | ||
* Search entities in db | ||
@@ -295,22 +284,2 @@ * | ||
driver(): OrmDriver; | ||
filterColumns(): { | ||
column: string; | ||
operators: FilterableOperators[]; | ||
}[]; | ||
filterSchema(): { | ||
type: string; | ||
oneOf: { | ||
type: string; | ||
required: string[]; | ||
properties: { | ||
field: { | ||
const: string; | ||
}; | ||
value: { | ||
type: string[]; | ||
}; | ||
operator: FilterableOperators[]; | ||
}; | ||
}[]; | ||
}; | ||
populate(this: ModelBase, relation: string, owner: ModelBase | number | string): SelectQueryBuilder; | ||
@@ -317,0 +286,0 @@ query(): SelectQueryBuilder; |
@@ -162,14 +162,2 @@ "use strict"; | ||
} | ||
/** | ||
* Get list of filterable columns for this model and allowed operators | ||
*/ | ||
static filterColumns() { | ||
throw new Error('Not implemented'); | ||
} | ||
/** | ||
* Gets filter columns schema for validation | ||
*/ | ||
static filterSchema() { | ||
throw new Error('Not implemented'); | ||
} | ||
static where(_column, _operator, _value) { | ||
@@ -658,34 +646,2 @@ throw new Error('Not implemented'); | ||
}, | ||
filterColumns() { | ||
const modelDescriptor = this.getModelDescriptor(); | ||
if (!modelDescriptor) { | ||
throw new exceptions_js_1.OrmException(`Model ${this.constructor.name} has no descriptor`); | ||
} | ||
return modelDescriptor.Columns.filter((c) => c.Filterable !== null && c.Filterable !== undefined && c.Filterable.length > 0).map((c) => { | ||
return { | ||
column: c.Name, | ||
operators: c.Filterable, | ||
}; | ||
}); | ||
}, | ||
filterSchema() { | ||
const modelDescriptor = this.getModelDescriptor(); | ||
if (!modelDescriptor) { | ||
throw new exceptions_js_1.OrmException(`Model ${this.constructor.name} has no descriptor`); | ||
} | ||
return { | ||
type: 'array', | ||
oneOf: modelDescriptor.Columns.filter((c) => c.Filterable !== null && c.Filterable !== undefined && c.Filterable.length > 0).map((c) => { | ||
return { | ||
type: 'object', | ||
required: ['field', 'value', 'operator'], | ||
properties: { | ||
field: { const: c.Name }, | ||
value: { type: ['string', 'integer'] }, | ||
operator: c.Filterable, | ||
}, | ||
}; | ||
}), | ||
}; | ||
}, | ||
populate(relation, owner) { | ||
@@ -718,4 +674,5 @@ //TODO: fix cast | ||
JoinQuery.leftJoin(relationDescriptor.TargetModel, function () { | ||
this.select(new builders_js_1.RawQuery(`'${this.TableAlias}'.*`)); | ||
this.select(new builders_js_1.RawQuery(`${this.TableAlias}.*`)); | ||
}); | ||
JoinQuery.where(relationDescriptor.SourceModel.getModelDescriptor().PrimaryKey, owner); | ||
JoinQuery.middleware(hydrateMiddleware); | ||
@@ -722,0 +679,0 @@ return JoinQuery; |
@@ -187,5 +187,5 @@ "use strict"; | ||
const cnt = driver.Container; | ||
this._database = driver.Options.Database; | ||
this._whereBuilder = cnt.resolve('SelectQueryBuilder', [driver, this._model, this]); | ||
this._whereBuilder.setAlias(this._tableAlias); | ||
this._whereBuilder.database(driver.Options.Database); | ||
this._whereCallback.call(this._whereBuilder, [this]); | ||
@@ -199,3 +199,3 @@ this._builder.mergeBuilder(this._whereBuilder); | ||
this._table = tDesc.TableName; | ||
this._primaryKey = sDesc.PrimaryKey; | ||
this._primaryKey = tDesc.PrimaryKey; | ||
this._alias = sAlias; | ||
@@ -202,0 +202,0 @@ this._foreignKey = relation.value.ForeignKey; |
@@ -33,3 +33,2 @@ import { IWhereBuilder } from './interfaces.js'; | ||
}; | ||
export type FilterableOperators = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'in' | 'nin' | 'between' | 'isnull' | 'notnull' | 'notbetween'; | ||
//# sourceMappingURL=types.d.ts.map |
import { Container, Constructor, IContainer } from '@spinajs/di'; | ||
import { ColumnType, QueryMethod, SortOrder, WhereBoolean, SqlOperator } from './enums.js'; | ||
import { IColumnsBuilder, ICompilerOutput, ILimitBuilder, IOrderByBuilder, IQueryBuilder, IQueryLimit, ISort, IWhereBuilder, QueryContext, IJoinBuilder, IBuilderMiddleware, IWithRecursiveBuilder, ReferentialAction, IGroupByBuilder, IUpdateResult, DefaultValueBuilder, ColumnAlterationType, QueryMiddleware, IBuilder, IDeleteQueryBuilder, IUpdateQueryBuilder, IFilter, ISelectQueryBuilder } from './interfaces.js'; | ||
import { IColumnsBuilder, ICompilerOutput, ILimitBuilder, IOrderByBuilder, IQueryBuilder, IQueryLimit, ISort, IWhereBuilder, QueryContext, IJoinBuilder, IBuilderMiddleware, IWithRecursiveBuilder, ReferentialAction, IGroupByBuilder, IUpdateResult, DefaultValueBuilder, ColumnAlterationType, QueryMiddleware, IBuilder, IDeleteQueryBuilder, IUpdateQueryBuilder, ISelectQueryBuilder } from './interfaces.js'; | ||
import { ColumnStatement, IQueryStatement, RawQueryStatement, Wrap } from './statements.js'; | ||
@@ -201,3 +201,2 @@ import { ModelDataWithRelationDataSearchable, PickRelations, Unbox, WhereFunction } from './types.js'; | ||
when(condition: boolean, callback?: WhereFunction<T>, callbackElse?: WhereFunction<T>): this; | ||
filter(filters: IFilter[]): this; | ||
where(column: string | boolean | WhereFunction<T> | RawQuery | Wrap | Partial<ModelDataWithRelationDataSearchable<Unbox<T>>> | PickRelations<T>, operator?: SqlOperator | any, value?: any): this; | ||
@@ -204,0 +203,0 @@ orWhere(column: string | boolean | WhereFunction<T> | RawQuery | Wrap | Partial<ModelDataWithRelationDataSearchable<Unbox<T>>>, ..._args: any[]): this; |
@@ -511,48 +511,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
} | ||
filter(filters) { | ||
filters.forEach((filter) => { | ||
switch (filter.Operator) { | ||
case 'eq': | ||
this.andWhere(filter.Column, SqlOperator.EQ, filter.Value); | ||
break; | ||
case 'neq': | ||
this.andWhere(filter.Column, SqlOperator.NOT, filter.Value); | ||
break; | ||
case 'gt': | ||
this.andWhere(filter.Column, SqlOperator.GT, filter.Value); | ||
break; | ||
case 'gte': | ||
this.andWhere(filter.Column, SqlOperator.GTE, filter.Value); | ||
break; | ||
case 'lt': | ||
this.andWhere(filter.Column, SqlOperator.LT, filter.Value); | ||
break; | ||
case 'lte': | ||
this.andWhere(filter.Column, SqlOperator.LTE, filter.Value); | ||
break; | ||
case 'like': | ||
this.andWhere(filter.Column, SqlOperator.LIKE, filter.Value); | ||
break; | ||
case 'in': | ||
this.andWhere(filter.Column, SqlOperator.IN, filter.Value); | ||
break; | ||
case 'nin': | ||
this.andWhere(filter.Column, SqlOperator.NOT_IN, filter.Value); | ||
break; | ||
case 'between': | ||
this.andWhere(filter.Column, SqlOperator.BETWEEN, filter.Value); | ||
break; | ||
case 'isnull': | ||
this.andWhere(filter.Column, SqlOperator.NULL); | ||
break; | ||
case 'notnull': | ||
this.andWhere(filter.Column, SqlOperator.NOT_NULL); | ||
break; | ||
case 'notbetween': | ||
this.andWhere(filter.Column, SqlOperator.NOT_BETWEEN, filter.Value); | ||
break; | ||
} | ||
}); | ||
return this; | ||
} | ||
where(column, operator, value) { | ||
@@ -876,2 +830,4 @@ const self = this; | ||
this._statements = this._statements.concat(stms); | ||
this._limit = builder._limit; | ||
this._sort = builder._sort; | ||
} | ||
@@ -878,0 +834,0 @@ min(column, as) { |
@@ -6,3 +6,2 @@ import { Constructor, IContainer } from '@spinajs/di'; | ||
import { Relation } from './relation-objects.js'; | ||
import { FilterableOperators } from './types.js'; | ||
export declare const MODEL_DESCTRIPTION_SYMBOL: unique symbol; | ||
@@ -57,3 +56,2 @@ export declare const MIGRATION_DESCRIPTION_SYMBOL: unique symbol; | ||
export declare function Primary(): any; | ||
export declare function Filterable(operators: FilterableOperators[]): any; | ||
/** | ||
@@ -60,0 +58,0 @@ * Marks columns as UUID. Column will be generated ad creation |
@@ -178,14 +178,2 @@ /* eslint-disable prettier/prettier */ | ||
} | ||
export function Filterable(operators) { | ||
return extractDecoratorDescriptor((model, _target, propertyKey) => { | ||
const columnDesc = model.Columns.find((c) => c.Name === propertyKey); | ||
if (!columnDesc) { | ||
// we dont want to fill all props, they will be loaded from db and mergeg with this | ||
model.Columns.push({ Name: propertyKey, Filterable: operators }); | ||
} | ||
else { | ||
columnDesc.Filterable = operators; | ||
} | ||
}, true); | ||
} | ||
/** | ||
@@ -192,0 +180,0 @@ * Marks columns as UUID. Column will be generated ad creation |
@@ -33,3 +33,3 @@ import { OrmException } from './exceptions.js'; | ||
} | ||
if (val.Type === RelationType.Many) { | ||
else { | ||
if (model[val.Name]) { | ||
@@ -36,0 +36,0 @@ const v = [...model[val.Name]]; |
@@ -5,3 +5,3 @@ import { Op } from './enums.js'; | ||
import { IQueryStatement, Wrap } from './statements.js'; | ||
import { FilterableOperators, ModelData, ModelDataWithRelationData, ModelDataWithRelationDataSearchable, PartialArray, PickRelations, Unbox, WhereFunction } from './types.js'; | ||
import { ModelData, ModelDataWithRelationData, ModelDataWithRelationDataSearchable, PartialArray, PickRelations, Unbox, WhereFunction } from './types.js'; | ||
import { IOrmRelation } from './relations.js'; | ||
@@ -27,7 +27,2 @@ import { OrmDriver } from './driver.js'; | ||
} | ||
export interface IFilter { | ||
Column: string; | ||
Operator: FilterableOperators; | ||
Value: any; | ||
} | ||
export interface IRelation<R extends ModelBase<R>, O extends ModelBase<O>> extends Array<R> { | ||
@@ -542,6 +537,2 @@ TargetModelDescriptor: IModelDescriptor; | ||
/** | ||
* If set column is fitlerable by this operators | ||
*/ | ||
Filterable?: FilterableOperators[]; | ||
/** | ||
* Default column value | ||
@@ -774,3 +765,2 @@ */ | ||
clearWhere(): this; | ||
filter(filter: IFilter[]): this; | ||
} | ||
@@ -777,0 +767,0 @@ export interface IWithRecursiveBuilder { |
@@ -1,2 +0,2 @@ | ||
import { FilterableOperators, ModelData, ModelDataWithRelationData, PartialArray, PickRelations } from './types.js'; | ||
import { ModelData, ModelDataWithRelationData, PartialArray, PickRelations } from './types.js'; | ||
import { IModelDescriptor, InsertBehaviour, IUpdateResult, ISelectQueryBuilder, IWhereBuilder, QueryScope, IHistoricalModel, IModelBase, IRelationDescriptor } from './interfaces.js'; | ||
@@ -58,13 +58,2 @@ import { WhereFunction } from './types.js'; | ||
/** | ||
* Get list of filterable columns for this model and allowed operators | ||
*/ | ||
static filterColumns(): { | ||
column: string; | ||
operators: FilterableOperators[]; | ||
}[]; | ||
/** | ||
* Gets filter columns schema for validation | ||
*/ | ||
static filterSchema(): any; | ||
/** | ||
* Search entities in db | ||
@@ -295,22 +284,2 @@ * | ||
driver(): OrmDriver; | ||
filterColumns(): { | ||
column: string; | ||
operators: FilterableOperators[]; | ||
}[]; | ||
filterSchema(): { | ||
type: string; | ||
oneOf: { | ||
type: string; | ||
required: string[]; | ||
properties: { | ||
field: { | ||
const: string; | ||
}; | ||
value: { | ||
type: string[]; | ||
}; | ||
operator: FilterableOperators[]; | ||
}; | ||
}[]; | ||
}; | ||
populate(this: ModelBase, relation: string, owner: ModelBase | number | string): SelectQueryBuilder; | ||
@@ -317,0 +286,0 @@ query(): SelectQueryBuilder; |
@@ -155,14 +155,2 @@ import { SortOrder } from './enums.js'; | ||
} | ||
/** | ||
* Get list of filterable columns for this model and allowed operators | ||
*/ | ||
static filterColumns() { | ||
throw new Error('Not implemented'); | ||
} | ||
/** | ||
* Gets filter columns schema for validation | ||
*/ | ||
static filterSchema() { | ||
throw new Error('Not implemented'); | ||
} | ||
static where(_column, _operator, _value) { | ||
@@ -648,34 +636,2 @@ throw new Error('Not implemented'); | ||
}, | ||
filterColumns() { | ||
const modelDescriptor = this.getModelDescriptor(); | ||
if (!modelDescriptor) { | ||
throw new OrmException(`Model ${this.constructor.name} has no descriptor`); | ||
} | ||
return modelDescriptor.Columns.filter((c) => c.Filterable !== null && c.Filterable !== undefined && c.Filterable.length > 0).map((c) => { | ||
return { | ||
column: c.Name, | ||
operators: c.Filterable, | ||
}; | ||
}); | ||
}, | ||
filterSchema() { | ||
const modelDescriptor = this.getModelDescriptor(); | ||
if (!modelDescriptor) { | ||
throw new OrmException(`Model ${this.constructor.name} has no descriptor`); | ||
} | ||
return { | ||
type: 'array', | ||
oneOf: modelDescriptor.Columns.filter((c) => c.Filterable !== null && c.Filterable !== undefined && c.Filterable.length > 0).map((c) => { | ||
return { | ||
type: 'object', | ||
required: ['field', 'value', 'operator'], | ||
properties: { | ||
field: { const: c.Name }, | ||
value: { type: ['string', 'integer'] }, | ||
operator: c.Filterable, | ||
}, | ||
}; | ||
}), | ||
}; | ||
}, | ||
populate(relation, owner) { | ||
@@ -708,4 +664,5 @@ //TODO: fix cast | ||
JoinQuery.leftJoin(relationDescriptor.TargetModel, function () { | ||
this.select(new RawQuery(`'${this.TableAlias}'.*`)); | ||
this.select(new RawQuery(`${this.TableAlias}.*`)); | ||
}); | ||
JoinQuery.where(relationDescriptor.SourceModel.getModelDescriptor().PrimaryKey, owner); | ||
JoinQuery.middleware(hydrateMiddleware); | ||
@@ -712,0 +669,0 @@ return JoinQuery; |
@@ -180,5 +180,5 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
const cnt = driver.Container; | ||
this._database = driver.Options.Database; | ||
this._whereBuilder = cnt.resolve('SelectQueryBuilder', [driver, this._model, this]); | ||
this._whereBuilder.setAlias(this._tableAlias); | ||
this._whereBuilder.database(driver.Options.Database); | ||
this._whereCallback.call(this._whereBuilder, [this]); | ||
@@ -192,3 +192,3 @@ this._builder.mergeBuilder(this._whereBuilder); | ||
this._table = tDesc.TableName; | ||
this._primaryKey = sDesc.PrimaryKey; | ||
this._primaryKey = tDesc.PrimaryKey; | ||
this._alias = sAlias; | ||
@@ -195,0 +195,0 @@ this._foreignKey = relation.value.ForeignKey; |
@@ -33,3 +33,2 @@ import { IWhereBuilder } from './interfaces.js'; | ||
}; | ||
export type FilterableOperators = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'in' | 'nin' | 'between' | 'isnull' | 'notnull' | 'notbetween'; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@spinajs/orm", | ||
"version": "2.0.223", | ||
"version": "2.0.224", | ||
"description": "framework orm module", | ||
@@ -58,6 +58,6 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@spinajs/configuration-common": "^2.0.223", | ||
"@spinajs/di": "^2.0.223", | ||
"@spinajs/exceptions": "^2.0.223", | ||
"@spinajs/log-common": "^2.0.223", | ||
"@spinajs/configuration-common": "^2.0.224", | ||
"@spinajs/di": "^2.0.224", | ||
"@spinajs/exceptions": "^2.0.224", | ||
"@spinajs/log-common": "^2.0.224", | ||
"glob": "^8.1.0", | ||
@@ -64,0 +64,0 @@ "glob-to-regexp": "^0.4.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1279278
17161