{"id":41728,"library":"pinia-orm","title":"Pinia ORM","description":"Pinia ORM is a plugin for Pinia that provides Object-Relational Mapping (ORM) capabilities for Vue 3 applications. Version 1.10.2 is the latest stable release with active development. It allows defining models with relationships (hasOne, hasMany, belongsTo, etc.) and provides a query builder for fluent data access. Key differentiators: seamless integration with Pinia's state management, support for reactive data, and TypeScript-first design. Released with a cadence of minor updates roughly every 2-3 months.","status":"active","version":"1.10.2","language":"javascript","source_language":"en","source_url":"https://github.com/CodeDredd/pinia-orm","tags":["javascript","vue","pinia","pinia-plugin","pinia-orm","orm","typescript"],"install":[{"cmd":"npm install pinia-orm","lang":"bash","label":"npm"},{"cmd":"yarn add pinia-orm","lang":"bash","label":"yarn"},{"cmd":"pnpm add pinia-orm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for Pinia store integration","package":"pinia","optional":false}],"imports":[{"note":"ESM-only package; useRepo is the main hook to interact with the repository.","wrong":"const { useRepo } = require('pinia-orm')","symbol":"useRepo","correct":"import { useRepo } from 'pinia-orm'"},{"note":"Model is a named export, not default. Extend it to define your data models.","wrong":"import Model from 'pinia-orm'","symbol":"Model","correct":"import { Model } from 'pinia-orm'"},{"note":"Plugin to install into Pinia. Use with pinia.use(PiniaOrmPlugin).","wrong":"","symbol":"PiniaOrmPlugin","correct":"import { PiniaOrmPlugin } from 'pinia-orm'"}],"quickstart":{"code":"import { createPinia } from 'pinia';\nimport { PiniaOrmPlugin, Model, useRepo, HasMany, BelongsTo } from 'pinia-orm';\nimport { createApp } from 'vue';\nimport App from './App.vue';\n\n// Define models\nclass User extends Model {\n  static entity = 'users';\n  static fields() {\n    return {\n      id: this.attr(null),\n      name: this.string(''),\n      posts: this.hasMany(Post, 'user_id'),\n    };\n  }\n}\n\nclass Post extends Model {\n  static entity = 'posts';\n  static fields() {\n    return {\n      id: this.attr(null),\n      title: this.string(''),\n      user_id: this.attr(null),\n      user: this.belongsTo(User, 'user_id'),\n    };\n  }\n}\n\n// Setup Vue app\nconst pinia = createPinia();\npinia.use(PiniaOrmPlugin);\nconst app = createApp(App);\napp.use(pinia);\n\n// Use repository\nconst repo = useRepo(User);\nrepo.save({ id: 1, name: 'Alice' });\nconst user = repo.find(1);\nconsole.log(user.name); // 'Alice'","lang":"typescript","description":"Shows setup of Pinia ORM with model definitions, relationships, and basic CRUD using useRepo."},"warnings":[{"fix":"Migrate from store.$orm() to useRepo() hook.","message":"Version 1.0.0 removed the 'orm' property from Pinia stores; useRepo is now required.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Define relations inside static fields() using 'this.hasMany()', etc.","message":"The 'HasOne', 'HasMany', 'BelongsTo' decorators are deprecated in favor of static fields() method.","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Ensure fields() returns an object literal with key-value pairs.","message":"Model fields must return plain objects, not arrays; otherwise reactivity may break.","severity":"gotcha","affected_versions":"*"},{"fix":"Change all imports to 'pinia-orm'.","message":"Upgrading from Pinia ORM v0.x to v1.x requires replacing '@pinia-orm/...' imports with 'pinia-orm'.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'-3':79 '1.10.2':23 '2':78 '3':20 'access':50 'activ':30 'allow':33 'applic':21 'belongsto':40 'builder':46 'cadenc':72 'capabl':17 'data':49,63 'defin':34 'design':68 'develop':31 'differenti':52 'etc':41 'everi':77 'first':67 'fluent':48 'hasmani':39 'hason':38 'integr':54 'javascript':81 'key':51 'latest':26 'manag':59 'map':15 'minor':74 'model':35 'month':80 'object':13 'object-rel':12 'orm':2,4,16,89,90 'pinia':1,3,9,56,83,85,88 'pinia-orm':87 'pinia-plugin':84 'plugin':7,86 'provid':11,43 'queri':45 'reactiv':62 'relat':14 'relationship':37 'releas':28,69 'rough':76 'seamless':53 'stabl':27 'state':58 'support':60 'typescript':66,91 'typescript-first':65 'updat':75 'version':22 'vue':19,82","created_at":"2026-06-04T18:53:49.244035+00:00","updated_at":"2026-06-04T18:53:49.244035+00:00","problems":[{"fix":"Run npm install pinia-orm pinia and ensure import is from 'pinia-orm'.","cause":"Missing package installation or incorrect import path.","error":"Cannot find module 'pinia-orm' or its corresponding type declarations."},{"fix":"Change require to import or use dynamic import().","cause":"Using CommonJS require() with an ESM-only package.","error":"Must use import to load ES Module: require() of ES modules is not supported."},{"fix":"Ensure you call pinia.use(PiniaOrmPlugin) before any store or repo usage.","cause":"Using useRepo or repository methods before Pinia ORM plugin is installed.","error":"TypeError: Cannot read properties of undefined (reading 'state')"},{"fix":"Import the model file at least once before using it (e.g., import './models/User').","cause":"Model class not imported or not registered into Pinia ORM.","error":"The target entity [entity] has not been registered."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/CodeDredd/pinia-orm#readme","github":"https://github.com/CodeDredd/pinia-orm","docs":null,"changelog":null,"pypi":null,"npm":"pinia-orm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}