Skip to content

Commit 548e4dc

Browse files
Nice trick
1 parent 59c6dc8 commit 548e4dc

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ import Model from './Model'
216216
export default class User extends Model {
217217

218218
// computed properties are reactive -> user.fullname
219-
get fullname()
219+
 // make sure to use "get" prefix
220+
 get fullname()
220221
{
221222
return `${this.firstname} ${this.lastname}`
222223
}
@@ -435,6 +436,32 @@ let users = await User
435436

436437
```
437438

439+
# Nice trick
440+
441+
You can build something like scoped queries.
442+
443+
```js
444+
import Model from './Model'
445+
446+
export default class Post extends Model {
447+
448+
  // make sure this is a static method
449+
  static active()  
450+
{
451+
// here you could chain more methods from vue-query-api
452+
     return this.where('status', 'active')
453+
  }
454+
}
455+
```
456+
So, you can do this:
457+
458+
```js
459+
let activePosts = await Post
460+
.active()
461+
.get()
462+
```
463+
464+
438465
# Response from backend
439466

440467
This package automatically handles the response from backend and convert it into an instance of a such Model.

0 commit comments

Comments
 (0)