TramwayJS

Entity

An entity is a basic object that represents a given schema.

Definition

Create

tramway create:entity Product --properties width height price

Locations

  • Implementation: src/entities

API

FunctionUsage
hasAttribute(attribute: string): booleanChecks if attribute is in the Entity
serialize(): stringReturns stringified JSON
unserialize(item): EntitySets own attributes based on serialized string

To create an entity, extend the class.

import { Entity } from 'tramway-core-connection';

Example

import { Entity } from 'tramway-core-connection';
export default class Product extends Entity {
getId() {
return this.id;
}
setId(id) {
this.id = id;
return this;
}
getWidth() {
return this.width;
}
setWidth(width) {
this.width = width;
return this;
}
getHeight() {
return this.height;
}
setHeight(height) {
this.height = height;
return this;
}
getPrice() {
return this.price;
}
setPrice(price) {
this.price = price;
return this;
}
}
export const _frontmatter = {"title":"Entity","metaTitle":"Entity | TramwayJS","metaDescription":"An entity is a basic object that represents a given schema."}