Class: CoreModel
Basic Object in Webda
It is used to define a data stored Any variable starting with _ can only be set by the server Any variable starting with __ won't be exported outside of the server
Webda Model
Extended by
Constructors
new CoreModel()
new CoreModel():
CoreModel
Returns
Source
packages/core/src/models/coremodel.ts:683
Properties
__class
__class:
CoreModelDefinition
<CoreModel
>
Class reference to the object
Source
packages/core/src/models/coremodel.ts:640
__ctx
__ctx:
OperationContext
<any
,any
>
Object context
@TJS-ignore
Source
packages/core/src/models/coremodel.ts:655
__dirty
__dirty:
Set
<string
|symbol
>
Source
packages/core/src/models/coremodel.ts:665
__store
__store:
Store
<CoreModel
,StoreParameters
,StoreEvents
>
If object is attached to its store
@TJS-ignore
Source
packages/core/src/models/coremodel.ts:662
__type
__type:
string
Type name
Source
packages/core/src/models/coremodel.ts:644
__types
__types:
string
[]
Types name
Source
packages/core/src/models/coremodel.ts:648
_creationDate
_creationDate:
Date
Creation date
Source
packages/core/src/models/coremodel.ts:670
_lastUpdate
_lastUpdate:
Date
Last update date
Source
packages/core/src/models/coremodel.ts:675
Methods
_onDelete()
_onDelete():
Promise
<void
>
Called when object is about to be deleted
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1593
_onDeleted()
_onDeleted():
Promise
<void
>
Called when object has been deleted
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1600
_onGet()
_onGet():
Promise
<void
>
Called when object is retrieved
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1607
_onSave()
_onSave():
Promise
<void
>
Called when object is about to be saved
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1614
_onSaved()
_onSaved():
Promise
<void
>
Called when object is saved
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1621
_onUpdate()
_onUpdate(
_updates
):Promise
<void
>
Called when object is about to be updates
Parameters
• _updates: any
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1630
_onUpdated()
_onUpdated():
Promise
<void
>
Called when object is updated
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1637
_toJSON()
_toJSON(
secure
):any
Remove the specific attributes if not secure
Parameters
• secure: any
serialize server fields also
Returns
any
filtered object to be serialized
Source
packages/core/src/models/coremodel.ts:1562
attributePermission()
attributePermission(
key
,value
,mode
,context
?):any
Allow to define custom permission per attribute
This method allows you to do permission based attribute But also a mask destructive attribute
Parameters
• key: string
• value: any
• mode: "READ"
| "WRITE"
• context?: OperationContext
<any
, any
>
Returns
any
updated value
Source
packages/core/src/models/coremodel.ts:1306
canAct()
canAct(
_context
,_action
):Promise
<string
|boolean
>
By default nothing is permitted on a CoreModel
Parameters
• _context: OperationContext
<any
, any
>
• _action: string
Returns
Promise
<string
| boolean
>
Source
packages/core/src/models/coremodel.ts:1221
checkAct()
checkAct(
context
,action
):Promise
<void
>
Parameters
• context: OperationContext
<any
, any
>
• action: string
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1197
delete()
delete():
Promise
<void
>
Delete this object
Returns
Promise
<void
>
Throws
Error if the object is not coming from a store
Source
packages/core/src/models/coremodel.ts:1457
generateUid()
generateUid(
_object
):string
Generate uuid for the object
Parameters
• _object: any
= undefined
Returns
string
Source
packages/core/src/models/coremodel.ts:1526
get()
get():
Promise
<CoreModel
>
Get the object
Returns
Promise
<CoreModel
>
Source
packages/core/src/models/coremodel.ts:1428
getContext()
getContext<
T
>():T
Get object context
Global object does not belong to a request
Type parameters
• T extends OperationContext
<any
, any
>
Returns
T
Source
packages/core/src/models/coremodel.ts:1413
getFullUuid()
getFullUuid():
string
Return a unique reference within the application to the object
It contains the Store containing it
Returns
string
Source
packages/core/src/models/coremodel.ts:1270
getProxy()
getProxy():
this
Return a proxy to the object to detect if dirty
Returns
this
Source
packages/core/src/models/coremodel.ts:1093
getRef()
getRef<
T
>():ModelRef
<T
>
Return a model ref
Type parameters
• T extends CoreModel
Returns
ModelRef
<T
>
Source
packages/core/src/models/coremodel.ts:1673
getService()
getService<
T
>(service
):T
Get a pre typed service
Type parameters
• T extends Service
<ServiceParameters
, Events
>
Parameters
• service: any
to retrieve WARNING: Only object attached to a store can retrieve service
Returns
T
Source
packages/core/src/models/coremodel.ts:1550
getStore()
getStore():
Store
<CoreModel
,StoreParameters
,StoreEvents
>
Return the object registered store
Returns
Store
<CoreModel
, StoreParameters
, StoreEvents
>
Source
packages/core/src/models/coremodel.ts:1420
getUuid()
getUuid():
string
Returns
string
the uuid of the object
Source
packages/core/src/models/coremodel.ts:1152
handleRelations()
protected
handleRelations():void
Patch every attribute that is based on a relation to add all the helpers
Returns
void
Source
packages/core/src/models/coremodel.ts:1353
incrementAttribute()
incrementAttribute(
property
,value
):Promise
<void
>
Increment an attribute both in store and object
Parameters
• property: never
• value: number
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1665
incrementAttributes()
incrementAttributes(
info
):Promise
<void
>
Increment a attributes both in store and object
Parameters
• info: Object
[]
Returns
Promise
<void
>
Source
packages/core/src/models/coremodel.ts:1681
isDirty()
isDirty():
boolean
Return true if needs a save
Returns
boolean
Source
packages/core/src/models/coremodel.ts:1144
load()
load(
raw
,secure
,relations
):this
Load an object from RAW
Parameters
data
• secure: boolean
= false
if false will ignore any _ variable
• relations: boolean
= true
Returns
this