@spinajs/orm
Advanced tools
Comparing version 2.0.286 to 2.0.288
@@ -578,2 +578,7 @@ import { Container, Constructor, IContainer } from '@spinajs/di'; | ||
Second: number; | ||
second(s: number): void; | ||
minute(m: number): void; | ||
hour(h: number): void; | ||
month(m: number): void; | ||
year(y: number): void; | ||
} | ||
@@ -580,0 +585,0 @@ export declare class EventQueryBuilder extends QueryBuilder { |
@@ -1520,2 +1520,17 @@ "use strict"; | ||
class EventIntervalDesc { | ||
second(s) { | ||
this.Second = s; | ||
} | ||
minute(m) { | ||
this.Minute = m; | ||
} | ||
hour(h) { | ||
this.Hour = h; | ||
} | ||
month(m) { | ||
this.Month = m; | ||
} | ||
year(y) { | ||
this.Year = y; | ||
} | ||
} | ||
@@ -1522,0 +1537,0 @@ exports.EventIntervalDesc = EventIntervalDesc; |
@@ -22,3 +22,3 @@ "use strict"; | ||
} | ||
obj[c.Name] = c.Converter ? c.Converter.toDB(val, model, c, model.ModelDescriptor.Converters.get(c.Name).Options) : val; | ||
obj[c.Name] = c.Converter ? c.Converter.toDB(val, model, c, model.ModelDescriptor.Converters.get(c.Name)?.Options) : val; | ||
}); | ||
@@ -25,0 +25,0 @@ return obj; |
import { Log } from '@spinajs/log-common'; | ||
import { IColumnDescriptor, IDriverOptions } from './interfaces.js'; | ||
import { IColumnDescriptor, IDriverOptions, ISupportedFeature } from './interfaces.js'; | ||
import { SyncService, IContainer, Container } from '@spinajs/di'; | ||
@@ -39,2 +39,6 @@ import { UpdateQueryBuilder, SelectQueryBuilder, IndexQueryBuilder, DeleteQueryBuilder, InsertQueryBuilder, SchemaQueryBuilder, QueryBuilder, TruncateTableQueryBuilder, Builder } from './builders.js'; | ||
abstract disconnect(): Promise<OrmDriver>; | ||
/** | ||
* Get list of supported features for this connection | ||
*/ | ||
abstract supportedFeatures(): ISupportedFeature; | ||
abstract tableInfo(name: string, schema?: string): Promise<IColumnDescriptor[]>; | ||
@@ -41,0 +45,0 @@ resolve(): void; |
@@ -31,3 +31,3 @@ "use strict"; | ||
Name: 'orm-driver', | ||
DefaultConnection: false | ||
DefaultConnection: false, | ||
}; | ||
@@ -34,0 +34,0 @@ this.Options = Object.assign(this.Options, options); |
@@ -26,2 +26,9 @@ import { Op } from './enums.js'; | ||
} | ||
export interface ISupportedFeature { | ||
/** | ||
* DB events support | ||
* To execute tasks accoriding to schedule in DB. | ||
*/ | ||
events: boolean; | ||
} | ||
export interface IRelation<R extends ModelBase<R>, O extends ModelBase<O>> extends Array<R> { | ||
@@ -28,0 +35,0 @@ TargetModelDescriptor: IModelDescriptor; |
@@ -149,3 +149,3 @@ import { ModelData, ModelDataWithRelationData, PartialArray, PickRelations } from './types.js'; | ||
*/ | ||
static getOrCreate<T extends typeof ModelBase>(this: T, _pk: any, _data?: Partial<InstanceType<T>>): Promise<InstanceType<T>>; | ||
static getOrCreate<T extends typeof ModelBase>(this: T, _pk: string | number | null, _data?: Partial<InstanceType<T>>): Promise<InstanceType<T>>; | ||
/** | ||
@@ -300,3 +300,3 @@ * Creates new model & saves is to db | ||
create<T_7 extends typeof ModelBase>(this: T_7, data: Partial<InstanceType<T_7>>): Promise<InstanceType<T_7>>; | ||
getOrCreate<T_8 extends typeof ModelBase>(this: T_8, pk: any, data: Partial<InstanceType<T_8>>): Promise<InstanceType<T_8>>; | ||
getOrCreate<T_8 extends typeof ModelBase>(this: T_8, pk: string | number | null, data: Partial<InstanceType<T_8>>): Promise<InstanceType<T_8>>; | ||
getOrNew<T_9 extends typeof ModelBase>(this: T_9, pk: any, data?: Partial<InstanceType<T_9>>): Promise<InstanceType<T_9>>; | ||
@@ -303,0 +303,0 @@ exists<T_10 extends typeof ModelBase>(this: T_10, pk: any): Promise<boolean>; |
@@ -421,4 +421,9 @@ "use strict"; | ||
afterQuery: (data) => { | ||
const response = sResponseMapper.read(data); | ||
this.PrimaryKeyValue = response.LastInsertId; | ||
const response = sResponseMapper.read(data, this.PrimaryKeyName); | ||
// if already exists do not overwrite | ||
// sometimes we have models with primary key as string etc | ||
// and not autoincrement | ||
if (!this.PrimaryKeyValue) { | ||
this.PrimaryKeyValue = response.LastInsertId; | ||
} | ||
}, | ||
@@ -824,3 +829,3 @@ modelCreation: () => null, | ||
description.Columns.filter((c) => c.Unique).forEach((c) => { | ||
query.andWhere(c, data[c.Name]); | ||
query.andWhere(c.Name, data[c.Name]); | ||
}); | ||
@@ -827,0 +832,0 @@ _prepareOrderBy(description, query); |
@@ -578,2 +578,7 @@ import { Container, Constructor, IContainer } from '@spinajs/di'; | ||
Second: number; | ||
second(s: number): void; | ||
minute(m: number): void; | ||
hour(h: number): void; | ||
month(m: number): void; | ||
year(y: number): void; | ||
} | ||
@@ -580,0 +585,0 @@ export declare class EventQueryBuilder extends QueryBuilder { |
@@ -1513,2 +1513,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
export class EventIntervalDesc { | ||
second(s) { | ||
this.Second = s; | ||
} | ||
minute(m) { | ||
this.Minute = m; | ||
} | ||
hour(h) { | ||
this.Hour = h; | ||
} | ||
month(m) { | ||
this.Month = m; | ||
} | ||
year(y) { | ||
this.Year = y; | ||
} | ||
} | ||
@@ -1515,0 +1530,0 @@ let EventQueryBuilder = class EventQueryBuilder extends QueryBuilder { |
@@ -18,3 +18,3 @@ import { OrmException } from './exceptions.js'; | ||
} | ||
obj[c.Name] = c.Converter ? c.Converter.toDB(val, model, c, model.ModelDescriptor.Converters.get(c.Name).Options) : val; | ||
obj[c.Name] = c.Converter ? c.Converter.toDB(val, model, c, model.ModelDescriptor.Converters.get(c.Name)?.Options) : val; | ||
}); | ||
@@ -21,0 +21,0 @@ return obj; |
import { Log } from '@spinajs/log-common'; | ||
import { IColumnDescriptor, IDriverOptions } from './interfaces.js'; | ||
import { IColumnDescriptor, IDriverOptions, ISupportedFeature } from './interfaces.js'; | ||
import { SyncService, IContainer, Container } from '@spinajs/di'; | ||
@@ -39,2 +39,6 @@ import { UpdateQueryBuilder, SelectQueryBuilder, IndexQueryBuilder, DeleteQueryBuilder, InsertQueryBuilder, SchemaQueryBuilder, QueryBuilder, TruncateTableQueryBuilder, Builder } from './builders.js'; | ||
abstract disconnect(): Promise<OrmDriver>; | ||
/** | ||
* Get list of supported features for this connection | ||
*/ | ||
abstract supportedFeatures(): ISupportedFeature; | ||
abstract tableInfo(name: string, schema?: string): Promise<IColumnDescriptor[]>; | ||
@@ -41,0 +45,0 @@ resolve(): void; |
@@ -28,3 +28,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
Name: 'orm-driver', | ||
DefaultConnection: false | ||
DefaultConnection: false, | ||
}; | ||
@@ -31,0 +31,0 @@ this.Options = Object.assign(this.Options, options); |
@@ -26,2 +26,9 @@ import { Op } from './enums.js'; | ||
} | ||
export interface ISupportedFeature { | ||
/** | ||
* DB events support | ||
* To execute tasks accoriding to schedule in DB. | ||
*/ | ||
events: boolean; | ||
} | ||
export interface IRelation<R extends ModelBase<R>, O extends ModelBase<O>> extends Array<R> { | ||
@@ -28,0 +35,0 @@ TargetModelDescriptor: IModelDescriptor; |
@@ -149,3 +149,3 @@ import { ModelData, ModelDataWithRelationData, PartialArray, PickRelations } from './types.js'; | ||
*/ | ||
static getOrCreate<T extends typeof ModelBase>(this: T, _pk: any, _data?: Partial<InstanceType<T>>): Promise<InstanceType<T>>; | ||
static getOrCreate<T extends typeof ModelBase>(this: T, _pk: string | number | null, _data?: Partial<InstanceType<T>>): Promise<InstanceType<T>>; | ||
/** | ||
@@ -300,3 +300,3 @@ * Creates new model & saves is to db | ||
create<T_7 extends typeof ModelBase>(this: T_7, data: Partial<InstanceType<T_7>>): Promise<InstanceType<T_7>>; | ||
getOrCreate<T_8 extends typeof ModelBase>(this: T_8, pk: any, data: Partial<InstanceType<T_8>>): Promise<InstanceType<T_8>>; | ||
getOrCreate<T_8 extends typeof ModelBase>(this: T_8, pk: string | number | null, data: Partial<InstanceType<T_8>>): Promise<InstanceType<T_8>>; | ||
getOrNew<T_9 extends typeof ModelBase>(this: T_9, pk: any, data?: Partial<InstanceType<T_9>>): Promise<InstanceType<T_9>>; | ||
@@ -303,0 +303,0 @@ exists<T_10 extends typeof ModelBase>(this: T_10, pk: any): Promise<boolean>; |
@@ -414,4 +414,9 @@ import { SortOrder } from './enums.js'; | ||
afterQuery: (data) => { | ||
const response = sResponseMapper.read(data); | ||
this.PrimaryKeyValue = response.LastInsertId; | ||
const response = sResponseMapper.read(data, this.PrimaryKeyName); | ||
// if already exists do not overwrite | ||
// sometimes we have models with primary key as string etc | ||
// and not autoincrement | ||
if (!this.PrimaryKeyValue) { | ||
this.PrimaryKeyValue = response.LastInsertId; | ||
} | ||
}, | ||
@@ -814,3 +819,3 @@ modelCreation: () => null, | ||
description.Columns.filter((c) => c.Unique).forEach((c) => { | ||
query.andWhere(c, data[c.Name]); | ||
query.andWhere(c.Name, data[c.Name]); | ||
}); | ||
@@ -817,0 +822,0 @@ _prepareOrderBy(description, query); |
{ | ||
"name": "@spinajs/orm", | ||
"version": "2.0.286", | ||
"version": "2.0.288", | ||
"description": "framework orm module", | ||
@@ -58,6 +58,6 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@spinajs/configuration-common": "^2.0.286", | ||
"@spinajs/di": "^2.0.286", | ||
"@spinajs/exceptions": "^2.0.286", | ||
"@spinajs/log-common": "^2.0.286", | ||
"@spinajs/configuration-common": "^2.0.288", | ||
"@spinajs/di": "^2.0.288", | ||
"@spinajs/exceptions": "^2.0.288", | ||
"@spinajs/log-common": "^2.0.288", | ||
"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
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
1294320
17426
+ Added@spinajs/configuration-common@2.0.306(transitive)
+ Added@spinajs/di@2.0.306(transitive)
+ Added@spinajs/exceptions@2.0.306(transitive)
+ Added@spinajs/log-common@2.0.306(transitive)
+ Added@spinajs/util@2.0.306(transitive)
- Removed@spinajs/configuration-common@2.0.308(transitive)
- Removed@spinajs/di@2.0.308(transitive)
- Removed@spinajs/exceptions@2.0.308(transitive)
- Removed@spinajs/log-common@2.0.308(transitive)
- Removed@spinajs/util@2.0.308(transitive)
Updated@spinajs/di@^2.0.288
Updated@spinajs/exceptions@^2.0.288
Updated@spinajs/log-common@^2.0.288