pinia-orm-edge
Welcome to pinia-orm
The intuitive, type safe and flexible ORM for Pinia — normalize relational data in your stores and query it like with an ORM.
Features
- Laravel-style query builder —
where,whereLike,whereHas,orderBy(incl.Intl.Collator),groupBy, aggregates,updateOrCreate/firstOrCreateand more - All the relations:
hasOne,hasMany,belongsTo,belongsToMany,hasManyThrough,morphOne,morphTo,morphMany,morphToMany,morphedByMany - Standard ECMAScript decorators for type safe model definitions
- Single Table Inheritance with nested discriminators, lifecycle hooks, mutators, casts, hidden fields and query caching
- First class Nuxt module (Nuxt 3 & 4) and an axios plugin
Quick start
npm install pinia pinia-orm
import { createPinia } from 'pinia'
import { createORM } from 'pinia-orm'
const pinia = createPinia().use(createORM())
import { Model, useRepo } from 'pinia-orm'
import { Attr, HasMany, Str, Uid } from 'pinia-orm/decorators'
class Todo extends Model {
static entity = 'todos'
@Uid() id!: string
@Str('') text!: string
@Attr(null) userId!: string | null
}
class User extends Model {
static entity = 'users'
@Uid() id!: string
@Str('') name!: string
@HasMany(() => Todo, 'userId') todos!: Todo[]
}
const userRepo = useRepo(User)
userRepo.save({ id: '1', name: 'John', todos: [{ text: 'Read the docs' }] })
const usersWithTodos = userRepo.with('todos').get()
Read the documentation for the full guide, or check the comparison with vuex-orm and the migration guide if you're upgrading.
Requirements
| pinia-orm | pinia | Node | TypeScript |
|---|---|---|---|
| 2.x | >= 3 | >= 22.12 | >= 5.2 |
| 1.x | 2.x | >= 14 | >= 4.x |
Help me keep working on this project 💚
💻 Development
- Clone this repository
- Enable Corepack using
corepack enable - Install dependencies using
pnpm install - Build the packages once with
pnpm build:stub && pnpm build:ci - Run tests using
pnpm test(orcd packages/pinia-orm && pnpm test:uifor the interactive UI)
Credits
Related projects
License
Made with ❤️
Published under MIT License.
Related Packages
pinia-orm
The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
404,131
528
pinia-cache
Cache dispatched actions in memory and prevent repeated requests and heavy actio...
1,372
2
Version History
Pre-releases (212)
| Version | Released | Vue | License |
|---|---|---|---|
| 2.0.1-29837481.c45bc34 | >=3.4.0 | MIT | |
| 2.0.1-29742817.3bbe949 | >=3.4.0 | MIT | |
| 2.0.1-29742814.59b656d | >=3.4.0 | MIT | |
| 2.0.0-29742807.e1ab103 | >=3.4.0 | MIT | |
| 2.0.0-29742803.35ad309 | >=3.4.0 | MIT | |
| 2.0.0-29742801.5332397 | >=3.4.0 | MIT | |
| 2.0.0-29742799.97f6e43 | >=3.4.0 | MIT | |
| 2.0.0-29742794.c4d55fb | >=3.4.0 | MIT | |
| 2.0.0-29742787.714cbb0 | >=3.4.0 | MIT | |
| 2.0.0-29742773.4ff579b | ^3.5.13 | MIT | |
| 2.0.0-29742764.05a9386 | ^3.5.13 | MIT | |
| 2.0.0-29742762.b414611 | ^3.5.13 | MIT | |
| 2.0.0-29398300.a7cc431 | ^3.5.13 | MIT | |
| 2.0.0-29394109.15c3f13 | ^3.5.13 | MIT | |
| 2.0.0-29393268.dff982c | ^3.5.13 | MIT | |
| 2.0.0-29392678.4bb7184 | ^3.5.13 | MIT | |
| 2.0.0-29146665.b053e2d | ^3.5.13 | MIT | |
| 2.0.0-29146664.16950b0 | ^3.5.13 | MIT | |
| 2.0.0-29071787.b1b8c27 | ^3.5.13 | MIT | |
| 2.0.0-29071784.ee571de | ^3.5.13 | MIT | |
| 2.0.0-29071780.bb25248 | ^3.5.13 | MIT | |
| 2.0.0-29071779.1c02d4e | ^3.5.13 | MIT | |
| 2.0.0-29071778.0a6c91f | ^3.5.13 | MIT | |
| 2.0.0-29018591.be8604a | ^3.5.13 | MIT | |
| 2.0.0-28997737.ac17289 | ^3.5.13 | MIT | |
| 2.0.0-28996950.cb0f4c0 | ^3.5.13 | MIT | |
| 2.0.0-28996940.796955e | ^3.5.13 | MIT | |
| 2.0.0-28996360.485786 | ^3.5.13 | MIT | |
| 2.0.0-28996332.a86dc5d | ^3.5.13 | MIT | |
| 2.0.0-28996328.d497326 | ^3.5.13 | MIT |
Showing the latest 30 of 212. See every release on npm
