API Reference
classes
Subjectentity

@coasys/ad4m / Exports / SubjectEntity

Class: SubjectEntity

Class representing a subject entity. Can extend this class to create a new subject entity to add methods interact with SDNA and much better experience then using the bare bone methods.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new SubjectEntity(perspective, baseExpression?, source?)

Constructs a new subject.

Parameters

NameTypeDescription
perspectivePerspectiveProxyThe perspective that the subject belongs to.
baseExpression?stringThe base expression of the subject.
source?string-

Defined in

subject/SubjectEntity.ts:31 (opens in a new tab)

Properties

#baseExpression

Private #baseExpression: string

Defined in

subject/SubjectEntity.ts:17 (opens in a new tab)


#perspective

Private #perspective: PerspectiveProxy

Defined in

subject/SubjectEntity.ts:20 (opens in a new tab)


#source

Private #source: string

Defined in

subject/SubjectEntity.ts:19 (opens in a new tab)


#subjectClass

Private #subjectClass: string

Defined in

subject/SubjectEntity.ts:18 (opens in a new tab)


author

author: string

Defined in

subject/SubjectEntity.ts:21 (opens in a new tab)


timestamp

timestamp: string

Defined in

subject/SubjectEntity.ts:22 (opens in a new tab)

Accessors

baseExpression

get baseExpression(): string

Gets the base expression of the subject.

Returns

string

Defined in

subject/SubjectEntity.ts:40 (opens in a new tab)

Methods

delete

delete(): Promise<void>

Delete the subject entity. This method will remove the subject from the perspective.

Returns

Promise<void>

Throws

Will throw an error if the subject entity cannot be removed.

Defined in

subject/SubjectEntity.ts:262 (opens in a new tab)


get

get(): Promise<SubjectEntity>

Get the subject entity with all the properties & collection populated.

Returns

Promise<SubjectEntity>

The subject entity.

Throws

Will throw an error if the subject entity cannot be converted to a subject class, or if the data of the subject entity cannot be gotten.

Defined in

subject/SubjectEntity.ts:249 (opens in a new tab)


getData

Private getData(id?): Promise<SubjectEntity>

Parameters

NameType
id?string

Returns

Promise<SubjectEntity>

Defined in

subject/SubjectEntity.ts:44 (opens in a new tab)


save

save(): Promise<void>

Save the subject entity. This method will create a new subject with the base expression and add a new link from the source to the base expression with the predicate "ad4m://has_child".

If a property has an action, it will perform the action (Only for collections). If a property is an array and is not empty, it will set the collection. If a property is not undefined, not null, and not an empty string, it will set the property.

Returns

Promise<void>

Throws

Will throw an error if the subject entity cannot be converted to a subject class, or if the subject cannot be created, or if the link cannot be added, or if the subject entity cannot be updated.

Defined in

subject/SubjectEntity.ts:183 (opens in a new tab)


setCollectionAdder

Private setCollectionAdder(key, value): Promise<void>

Parameters

NameType
keystring
valueany

Returns

Promise<void>

Defined in

subject/SubjectEntity.ts:140 (opens in a new tab)


setCollectionRemover

Private setCollectionRemover(key, value): Promise<void>

Parameters

NameType
keystring
valueany

Returns

Promise<void>

Defined in

subject/SubjectEntity.ts:156 (opens in a new tab)


setCollectionSetter

Private setCollectionSetter(key, value): Promise<void>

Parameters

NameType
keystring
valueany

Returns

Promise<void>

Defined in

subject/SubjectEntity.ts:123 (opens in a new tab)


setProperty

Private setProperty(key, value): Promise<void>

Parameters

NameType
keystring
valueany

Returns

Promise<void>

Defined in

subject/SubjectEntity.ts:106 (opens in a new tab)


update

update(): Promise<void>

Update the subject entity.

It will iterate over the properties of the subject entity.

If a property has an action, it will perform the action (Only for collections). If a property is an array and is not empty, it will set the collection. If a property is not undefined, not null, and not an empty string, it will set the property.

Returns

Promise<void>

Throws

Will throw an error if the subject entity cannot be converted to a subject class, or if a property cannot be set, or if a collection cannot be set, or if the data of the subject entity cannot be gotten.

Defined in

subject/SubjectEntity.ts:210 (opens in a new tab)


all

Static all(perspective): Promise<any[]>

Get all the subject entities of the subject class.

NOTE: this is a static method and should be called on the class itself.

Parameters

NameTypeDescription
perspectivePerspectiveProxyThe perspective that the subject belongs to.

Returns

Promise<any[]>

The subject entities.

Throws

Will throw an error if the subject entity cannot be converted to a subject class, or if the subject proxies cannot be gotten.

Defined in

subject/SubjectEntity.ts:277 (opens in a new tab)


query

Static query(perspective, query?): Promise<SubjectEntity[]>

Query the subject entities of the subject class.

NOTE: this is a static method and should be called on the class itself.

Parameters

NameTypeDescription
perspectivePerspectiveProxyThe perspective that the subject belongs to.
query?SubjectEntityQueryParamThe query of the subject entities.

Returns

Promise<SubjectEntity[]>

The subject entities.

Throws

Will throw an error if the subject entity cannot be converted to a subject class, or if the query cannot be inferred, or if the data of the subject entities cannot be gotten.

Defined in

subject/SubjectEntity.ts:308 (opens in a new tab)