0.1.9 • Published 4 years ago

@adityahegde/models v0.1.9

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

typescript-models

Utility package used to define models for a react app. Used to configure @adityahegde/server and @adityahegde/react-components packages.

Creating a Model

To create a model in the ecosystem the model class has to extend BaseType and have ModelMetadata.Model decorator.

import {
  ModelMetadata,
  TextField,
  DisplayField,
} from "@adityahegde/models";

@ModelMetadata.Model({
  // Overrides the singular representation.
  // By default it will be class name with 1st letter as lower case. 
  singular: "sample",
  // Overrides the plural representation.
  // By default it will be output of pluralize pacakge of singular attribute.
  plural: "samples",
  // API base for the model. This is used to build the api route for this model.
  // apiPath = `${apiBase}/${plural}`
  apiBase: "/api",
  // Specifies the base class for a polymorphic inheritance.
  // NOTE: Not implemented just yet.
  polymorphic: "",
})
class SampleModel extends BaseType {
  @DisplayField()
  // Add field decorators at the end for other decorators to work
  @TextField()
  public textField: string;
}

Check docs/modules.md for API documentation.

Check sample-products-app for a real world example.

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago