Skip to content

Commit 55c0f33

Browse files
authored
Update README.md
1 parent c3f454d commit 55c0f33

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,39 @@ import { JSORMBase, Model, Attr, HasMany } from "jsorm"
1313

1414
class ApplicationRecord extends JSORMBase {
1515
static baseUrl = "http://localhost:3000"
16-
static jsonapiType = "people"
16+
static apiNamespace = "/api/v1"
1717
}
1818

1919
@Model()
2020
class Person extends ApplicationRecord {
21+
static jsonapiType = "people"
22+
2123
@Attr() firstName: string
2224
@Attr() lastName: string
2325

26+
@HasMany() pets: Pet[]
27+
2428
get fullName() {
2529
return `${this.firstName} ${this.lastName}`
2630
}
2731
}
2832

33+
@Model()
34+
class Pet extends ApplicationRecord {
35+
static jsonapiType = "pets"
36+
37+
@Attr() name: string
38+
}
39+
2940
let { data } = await Person
3041
.where({ name: 'Joe' })
3142
.page(2).per(10)
3243
.sort('name')
44+
.includes("pets")
3345
.all()
3446

3547
let names = data.map((p) => { return p.fullName })
3648
console.log(names) // ['Joe Blow', 'Joe DiMaggio', ...]
49+
50+
console.log(data[0].pets[0].name) // "Fido"
3751
```

0 commit comments

Comments
 (0)