Skip to content

Commit

Permalink
add support for _created field to thing model
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Weirich <matthias.weirich@selectcode.de>
  • Loading branch information
vavido committed Apr 9, 2021
1 parent b6a0eec commit cbf58e0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions javascript/lib/api/src/model/things.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export class Thing extends EntityWithId {
private readonly __modified?: string,
private readonly _acl?: Acl,
private readonly _definition?: string,
private readonly __metadata?: Metadata) {
private readonly __metadata?: Metadata,
private readonly __created?: string) {
super();
}

Expand All @@ -52,11 +53,13 @@ export class Thing extends EntityWithId {
o['_modified'],
Acl.fromObject(o['acl']),
o['definition'],
Metadata.fromObject(o['_metadata']));
Metadata.fromObject(o['_metadata']),
o['_created']
);
}

public static empty(): Thing {
return new Thing('', '', undefined, undefined, 0, '', undefined, undefined, undefined);
return new Thing('', '', undefined, undefined, 0, '', undefined, undefined, undefined, undefined);
}

public toObject(): object {
Expand All @@ -70,7 +73,8 @@ export class Thing extends EntityWithId {
['_revision', this._revision],
['_modified', this._modified],
['acl', aclObj],
['definition', this._definition]
['definition', this._definition],
['_created', this.__created]
]));
}

Expand Down Expand Up @@ -122,6 +126,10 @@ export class Thing extends EntityWithId {
return this._definition;
}

get created(): string | undefined {
return this.__created;
}

private separateNamespaceAndThingId(): { namespace: string, name: string } {
const indexOfFirstColon = this.thingId.indexOf(':');
if (indexOfFirstColon >= 0) {
Expand Down

0 comments on commit cbf58e0

Please sign in to comment.