Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
doc(decorator): Added docs for type decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
RWOverdijk committed Feb 23, 2016
1 parent 893e3e8 commit fe290b8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions doc/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,40 @@ Use this decorator to indicate that a property has a relationship with another e
- It will make sure that calling .asObject() on the entity recursively converts all children to simple objects.
- It will make sure that upon calling .update(), all children get converted to IDs.

## @type()
This decorator allows you to add types to your properties. These types will be used **when populating an entity**, to cast the values to given type. This can be useful when, for instance, working with `Date` instances.

### Example
```javascript
import {Entity, type} from 'spoonx/aurelia-orm';

export class MyEntity extends Entity {
@type('string')
name = null;

@type('date')
created = null;

@type('boolean')
disabled = false;
}
```

### Accepted types
The accepted types are:

- text
- string
- date
- datetime
- integer
- int
- number
- float
- boolean
- bool
- smart (autodetect based on value)

## @endpoint()
This decorator allows you to specify which endpoint (see the [aurelia-api documentation](https://github.com/SpoonX/aurelia-api/blob/master/doc/getting-started.md#multiple-endpoints)) to use.

Expand Down

0 comments on commit fe290b8

Please sign in to comment.