Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response Entity with relationships (withAll()) #78

Open
crazymind opened this issue Oct 28, 2019 · 2 comments
Open

Response Entity with relationships (withAll()) #78

crazymind opened this issue Oct 28, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@crazymind
Copy link

Let's take this model as example:

 export default class Transfer extends Model {
  static entity = 'transfers'

  static fields () {
    return {
      id: this.attr(null),
      files: this.hasMany(File, 'transfer_id'),
      links: this.hasMany(Link, 'transfer_id'),
    }
  }

Currently we receive the entities all separated. But it would be nice if the requested model would also had the objects included (like if you would execute query().withAll())

return Transfer.api().get(`/transfers/${transferId}`)
    .then((response) => {

      console.log(response.entities.transfers)
      console.log(response.entities.files)
      console.log(response.entities.links)
     
      // Have to query to this way to get files
      let transfer = Transfer.query()
        .withAll()
        .where({
          id: response.entities.transfers[0]
        })
        .first();
     
      commit('doSomething', transfer)
    })
@kiaking kiaking added the enhancement New feature or request label Oct 29, 2019
@kiaking
Copy link
Member

kiaking commented Oct 29, 2019

Yeah, I know. This will be solved if Vuex ORM manages to implement a "lazy load" feature, which is currently an active issue at Vuex ORM Core.

I'll keep the issue open as an enhancement, so we can keep tracking!

@xorinzor
Copy link

@kiaking any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants