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 relationconst 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 pina 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 createdconst userRepo = useRepo(User)// ✅ works because the pinia instance is passed to defineSotreconst 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/dist/helpers