Skip to content

How to use pinia orm with computed properties #957

Answered by garma83
garma83 asked this question in Q&A
Discussion options

You must be logged in to vote

I have something of a solution maybe? But its not working yet. Would appreciate feedback.

I have the below in the model:

static piniaOptions = {
    state: () => ({
        data: {},
        currentId: <number | string | null>null,
    }),
    getters: {
        current(this: DataStore) {
            return this.currentId ? this.data[this.currentId] : null;
        }
    }
}

The above doesnt work because it doesnt return a valid instance (pinia orm did not work its magic on it)

One complicating factor is that in the getter I dont have access to the Model directly. All models are inherited from a single model (Called MyModel) . This is so I dont have to repeat all the logic for currents (…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CodeDredd
Comment options

Answer selected by CodeDredd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants