UNPKG

sarala

Version:

Javascript library to communicate with RESTful API built following JSON API specification. inspired by Laravel’s Eloquent.

37 lines (27 loc) 607 B
--- sidebarDepth: 0 --- ## Sparse Fieldsets #### Specify only root resource fields ```javascript const post = new Post() let result = await post.select(['title', 'subtitle']).find(8) // ... ``` ``` GET /posts?fields[posts]=title,subtitle Accept: application/vnd.api+json ``` #### Specify fields of root and related resources ```javascript const post = new Post() let result = await post.select({ posts: ['title', 'subtitle'], tags: ['name'] }).with(['tags']).find(8) // ... ``` ``` GET /posts?include=tags&fields[posts]=title,subtitle&fields[tags]=name Accept: application/vnd.api+json ```