0.0.1 • Published 7 years ago
typux-model v0.0.1
DANGER! Under deep development
typux-http
HTTP plugin for typux
Installation
npm install typux-model
or
yarn add typux-model
Usage
Models
export class Post
{
@TypeOf(Number)
public id : number;
@TypeOf(Number)
@Default(100)
public order : number;
@TypeOf(Boolean)
public favorite : boolean;
@TypeOf(Date)
public postedAt : Date;
@ListOf(Comment)
public comments : Comment[];
}
export class Comment
{
...
}
Convert
import {Converter} from 'typux-model';
const converter = new Converter();
const post = converter.convertTo(Post, {
id : '1',
'favorite' : 0,
postedAt : '2017-02-11 12:23:32',
comments : [
{...},
{...}
}
})
0.0.1
7 years ago