Skip to content

Possibility to access data from one store to another for accessors & mutators #341

Answered by CodeDredd
whitespacecode asked this question in Q&A
Discussion options

You must be logged in to vote

With custom repositories you can define what you like.
I think it should be possible to access related data with an getter. But i think the solution i post you is not very performant on big data.
The way you posted child doesn't make sense to access parent data. You need some relation inside the model and not importing the model.

import { Model } from "pinia-orm";
import { Adult } from "./Adult";

export class Person extends Model {
  static entity = 'person';

  static fields () {
       return {
           id: this.attr(null),
           name: this.attr('')
           adults: this.hasMany(Adult, 'person_id')
       }
   }

   get checkForX () {
        return this.name.toLowerCase().inc…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
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