Under the hood Pinia ORM uses the defineStore
method to create the pinia store for each model. You still have of course the
option to pass pinia options through a configuration in the model
Maybe you want to use some other pinia plugins like Pinia Plugin Persistedstate. And therefor you need to be able to pass otpions to your store definition.
import { Model, Attr, Str } from 'pinia-orm'import Post from '@/models/Post'class User extends Model { static entity = 'users' @Attr(null) id!: number | null @Str('') name!: string static piniaOptions = { persist: true }}
Through this options you can also overwrite the default pinia actions and add even properties to the state.
import { Model, Attr, Str, useStoreActions, Elements } from 'pinia-orm'import Post from '@/models/Post'class User extends Model { static entity = 'users' @Attr(null) id!: number | null @Str('') name!: string static piniaOptions = { actions: { ...useStoreActions(), save(records: Elements) { console.log('I am saving data!') this.data = { ...this.data, ...records } }, } }}