Registry / storage / vuex-orm-decorators

vuex-orm-decorators

JSON →
library2.0.3jsnpmunverified

TypeScript decorators (v2.0.3) for Vuex ORM v0.36, providing typed property access and auto-registration of models via the ORMDatabase plugin. Superseded by Vuex ORM Next; Vuex itself is deprecated in favor of Pinia. Ships TypeScript declarations, targets es2015, and is compatible with Vue 2/Vuex 3 and Vue 3/Vuex 4. Requires manual transpile for es5 targets and Nuxt.js projects.

npm install vuex-orm-decorators
INSTALL
IMPORT
SIG · VUEX-ORM-DECORATOR
V
vuex-orm-decorators
storagejavascriptv2.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ORMDatabase
import { ORMDatabase } from 'vuex-orm-decorators'
const ORMDatabase = require('vuex-orm-decorators').ORMDatabase
ESM-only package; CommonJS require may break in certain bundlers. Use default import for auto-registration.
Model
import { Model } from 'vuex-orm-decorators'
import Model from 'vuex-orm-decorators'
Model is a named export, not a default export.
Fields
import { Fields } from 'vuex-orm-decorators'
import { Fields } from '@vuex-orm/core'
Fields decorator is re-exported by vuex-orm-decorators; do not import from the core package.

Shows auto-registration of a Vuex ORM model using decorators and ORMDatabase plugin.

import Vue from 'vue'; import Vuex from 'vuex'; import { ORMDatabase, Model, Fields, Str, Num } from 'vuex-orm-decorators'; Vue.use(Vuex); const store = new Vuex.Store({ plugins: [ORMDatabase.install({ namespace: 'Models' })] }); class User extends Model { static entity = 'users'; static primaryKey = 'id'; @Fields({ id: Num, name: Str, email: Str }) declare id: number; declare name: string; declare email: string; } // User is automatically registered. console.log(store.state.Models.users);
Debug
Known issues
deprecatedVuex ORM is deprecated. Use Vuex ORM Next (vuex-orm-next) or switch to Pinia for new projects.
fix
Migrate to @vuex-orm/plugin or Pinia; see https://next.vuex-orm.org
affects: >=0.0.0
deprecatedVuex itself is deprecated in favor of Pinia. The library may not receive updates.
fix
Consider using Pinia for state management.
affects: >=0.0.0
breakingRequires @vuex-orm/core@^0.36; incompatible with newer versions (0.37+).
fix
Pin @vuex-orm/core to ^0.36.1 in package.json.
affects: >=2.0.0
gotchaModel properties must use 'declare' keyword when decorated; omitting it causes a TypeScript error.
fix
Add 'declare' before property name: @Fields(...) declare name: string;
affects: >=1.0.0
gotchaAuto-model registration via ORMDatabase may not work in SSR environments.
fix
Manually register models using Vuex ORM's Database plugin.
affects: >=1.0.0
gotchaLibrary targets es2015; using with es5 requires configuring Vue CLI to transpile it.
fix
In vue.config.js: transpileDependencies: ['vuex-orm-decorators']
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'vuex-orm-decorators' or its corresponding type declarations.
TypeScript cannot locate the package or its type definitions.
fix
Ensure package is installed with --save-dev (types included). Set 'moduleResolution' to 'node'.
Decorators are not valid here. ts(1206)
Missing 'experimentalDecorators': true in tsconfig.json.
fix
Add 'experimentalDecorators': true and 'importHelpers': true to tsconfig.json.
TypeError: Cannot read properties of undefined (reading 'install')
Vuex not installed or not used before ORMDatabase.install().
fix
Install and call Vue.use(Vuex) before creating the store.
Model is not registered in the database.
Model class not imported/used anywhere before store creation, or ORMDatabase not installed.
fix
Import the model file to trigger auto-registration, or use ORMDatabase.install().
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
@vuex-orm/corerequiredPeer dependency: Vuex ORM core library (v0.36.x). The decorators require this specific version range.
vuexrequiredPeer dependency: Vuex v3 (Vue 2) or v4 (Vue 3). Required for the ORMDatabase plugin.
Agent activity
27 hits · last 30 days
node
24
Resources
vuex-orm-decorators — npm install vuex-orm-decorators · libregistry