Last active
March 27, 2018 10:49
-
-
Save zaru/d71a38f9ea10613c933c07805c7420dc to your computer and use it in GitHub Desktop.
dynamic chain object, vuex-orm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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