@spinajs/orm
Advanced tools
Comparing version 1.2.192 to 1.2.194
@@ -8,3 +8,56 @@ import { IModelDescriptor, InsertBehaviour, IUpdateResult, IWhereBuilder } from './interfaces'; | ||
export declare function extractModelDescriptor(targetOrForward: any): IModelDescriptor; | ||
export declare class ModelBase { | ||
export interface IModelBase { | ||
ModelDescriptor: IModelDescriptor; | ||
Container: IContainer; | ||
PrimaryKeyName: string; | ||
PrimaryKeyValue: any; | ||
getFlattenRelationModels(): IModelBase[]; | ||
/** | ||
* Fills model with data. It only fills properties that exists in database | ||
* | ||
* @param data - data to fill | ||
*/ | ||
hydrate(data: Partial<this>): void; | ||
/** | ||
* | ||
* Attachess model to proper relation an sets foreign key | ||
* | ||
* @param data - model to attach | ||
*/ | ||
attach(data: ModelBase): void; | ||
/** | ||
* Extracts all data from model. It takes only properties that exists in DB | ||
*/ | ||
dehydrate(includeRelations?: boolean, omit?: string[]): Partial<this>; | ||
/** | ||
* deletes enitt from db. If model have SoftDelete decorator, model is marked as deleted | ||
*/ | ||
destroy(): Promise<void>; | ||
/** | ||
* If model can be in achived state - sets archived at date and saves it to db | ||
*/ | ||
archive(): Promise<void>; | ||
update(): Promise<void>; | ||
/** | ||
* Save all changes to db. It creates new entry id db or updates existing one if | ||
* primary key exists | ||
*/ | ||
insert(insertBehaviour: InsertBehaviour): Promise<IUpdateResult>; | ||
/** | ||
* Gets model data from database and returns as fresh instance. | ||
* | ||
* If primary key is not fetched, tries to load by columns with unique constraint. | ||
* If there is no unique columns or primary key, throws error | ||
*/ | ||
fresh(): Promise<this>; | ||
/** | ||
* Refresh model from database. | ||
* | ||
* If no primary key is set, tries to fetch data base on columns | ||
* with unique constraints. If none exists, throws exception | ||
*/ | ||
refresh(): Promise<void>; | ||
toJSON(): any; | ||
} | ||
export declare class ModelBase implements IModelBase { | ||
private _container; | ||
@@ -11,0 +64,0 @@ /** |
import { IRelationDescriptor, IModelDescriptor, InsertBehaviour, ForwardRefFunction, IBuilderMiddleware } from './interfaces'; | ||
import { Constructor } from '@spinajs/di'; | ||
import { SelectQueryBuilder } from './builders'; | ||
import { ModelBase } from './model'; | ||
import { IModelBase, ModelBase } from './model'; | ||
import { Orm } from './orm'; | ||
@@ -76,3 +76,3 @@ export interface IOrmRelation { | ||
} | ||
export declare class SingleRelation<R extends ModelBase> implements IRelation { | ||
export declare class SingleRelation<R extends IModelBase> implements IRelation { | ||
protected _owner: ModelBase; | ||
@@ -79,0 +79,0 @@ protected model: Constructor<R> | ForwardRefFunction; |
{ | ||
"name": "@spinajs/orm", | ||
"version": "1.2.192", | ||
"version": "1.2.194", | ||
"description": "framework orm module", | ||
@@ -55,3 +55,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "66b10674ad7d527a8abbbbef0c508ed908fa8912" | ||
"gitHead": "a0e0212d10a889112e0f61bdce50be020fa7df26" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
384571
6657