Skip to content

Commit f3bba11

Browse files
author
Lee Richmond
committed
Update README.md
1 parent ba04f4b commit f3bba11

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ Written in [Typescript](https://www.typescriptlang.org) and distributed in ES5,
66

77
(Open to better names for this lib :grin:)
88

9+
### Sample Usage
10+
11+
Please see [our documentation page](https://bbgithub.dev.bloomberg.com/pages/lrichmon/jsorm) for full usage.
12+
13+
```es6
14+
import { Config, Model, attr, hasMany, belongsTo } from 'jsorm';
15+
16+
const Person = Model.extend({
17+
static {
18+
baseUrl: 'http://localhost:3000',
19+
jsonapiType: 'people'
20+
},
21+
22+
firstName: attr(),
23+
lastName: attr(),
24+
fullName() {
25+
return this.firstName + ' ' + this.lastName;
26+
}
27+
});
28+
29+
Person.where({ name: 'Joe' }).page(2).per(10).sort('name').then((people) => {
30+
let names = people.map((p) => { return p.fullName(); });
31+
console.log(names); // ['Joe Blow', 'Joe DiMaggio', ...]
32+
});
33+
```
34+
935
### Roadmap
1036

1137
* Find to throw error when record not found

0 commit comments

Comments
 (0)