File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,8 @@ import Model from './Model'
216
216
export default class User extends Model {
217
217
218
218
// computed properties are reactive -> user.fullname
219
- get fullname ()
219
+ // make sure to use "get" prefix
220
+ get fullname ()
220
221
{
221
222
return ` ${ this .firstname } ${ this .lastname } `
222
223
}
@@ -435,6 +436,32 @@ let users = await User
435
436
436
437
```
437
438
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
+
438
465
# Response from backend
439
466
440
467
This package automatically handles the response from backend and convert it into an instance of a such Model.
You can’t perform that action at this time.
0 commit comments