Skip to content

Instantly share code, notes, and snippets.

@zaru
Last active March 27, 2018 10:49
Show Gist options
  • Save zaru/d71a38f9ea10613c933c07805c7420dc to your computer and use it in GitHub Desktop.
Save zaru/d71a38f9ea10613c933c07805c7420dc to your computer and use it in GitHub Desktop.
dynamic chain object, vuex-orm
let chains = [
{
key: 'where',
args: ['form_id', formId]
},
{
key: 'where',
args: ['assignee_id', Number(params.assignee_id)]
}
,{
key: 'whereHas',
args: ['entry_labels', (query) => {
query.where('label_id', params.l)
}]
}
}
let ref = getters['entities/entries/query']().withAll()
chains.forEach((val) => { ref = ref[val.key](...val.args)})
return ref.orderBy('id', 'desc').get()
return getters['entities/entries/query']()
.withAll()
.where('form_id', formId)
.where('assignee_id', params.assignee_id)
.whereHas('entry_labels', (query) => {
query.where('label_id', params.l)
})
.orderBy('id', 'desc')
.get()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment