Comments (6)
from vue-api-query.
You can create new instances manually. See on README.
let post = new Post()
post.id = 123
// or just pass as a payload
let post = new Post({id: 123})
// of course you can pass any other params
Then..
// GET /posts/123/comments
let comments = await post.comments().get()
Make sure Post
and Comment
extends from a BaseModel
.
from vue-api-query.
Awesome, thanks! This method seems to work with get
but not find
as far as I can tell, though? So, modeling off of your example, I have:
const User = new User({id: 1})
const Post = await User.posts().find(2)
This fires "/posts/2" instead of "/users/1/posts/2".
from vue-api-query.
The find()
method is suposed to be used with single resources.
For nested resources you should always use get()
.
As described on README you can use another methods before get()
on nested resources.
await user.posts().where('id', 2).get()
from vue-api-query.
Okie dok. Is there some philosophy behind the find()
method not being able to be used with nested resources? I thought nested resources with multiple identifiers was a common REST API pattern?
from vue-api-query.
@Dylan-Chapman Now you can do this
const User = new User({id: 1})
const Post = await User.posts().find(2)
Just upgrade to 1.1.0
. Thanks @vjoao for PR!
from vue-api-query.
Related Issues (20)
- Add when() method HOT 1
- Model defaults/Model override documentation suggestion HOT 3
- How to add default attributes HOT 1
- Please include `src` into npm package HOT 1
- Nested primaryKey problem HOT 1
- Extra arguments (params) to find method HOT 1
- [Question] Is the project still maintained and support for Vue 3? HOT 2
- groupby support HOT 1
- model.patch does not change the method to PATCH HOT 2
- Nuxt 3 support ? HOT 3
- Discussion about array format breaking change HOT 1
- Exporting data as Excel HOT 3
- Is there a way to use an Axios Canceltoken or better: the native AbortController in combination with this package?
- adding equals to whereNull and whereNot function
- Custom endpoints for CRUD actions HOT 1
- Can't build query with nested primaryKey
- TS: fields disappear when defined HOT 1
- Could not resolve "@babel/runtime/helpers/" functions. HOT 1
- usage with ofetch
- How to cache data ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-api-query.