Usage
Standard
There is only one little difference between vuex-orm-next and pinia-orm usage. You need to use useRepo
import User from './models/User'
import { useRepo } from 'pinia-orm'
const userRepo = useRepo(User)
// Getting all users with their todos as relation
const users = userRepo.with('todos').get()
Outside of setup()
You can also use pinia-orm out of the store. Like in pinia you need then to pass the pinia
instance to useRepo
See using pinia outside of setup
import User from '@/models/User'
import { createApp } from 'vue'
import App from './App.vue'
// โ fails because it's called before the pinia is created
const userRepo = useRepo(User)
// โ
works because the pinia instance is passed to defineStore
const userRepo = useRepo(User, this.$pinia)
Helpers
Look into the Api Guide for usages of useCollect
and more
The nice thing of these composables is that they work also with existing vuex-orm
and vuex-orm-net
. So if you like them
you can just import these helpers e.g. by import { useCollect }
from pinia-orm/helpers
Table of Contents