Skip to content
Projets

À propos

Plugin Pinia permettant d’accéder au Store Pinia via un mappage objet-relationnel (ORM).

Outils de développement

Comment ces chiffres sont mesurés

What you can do

  • Laravel-style query builder — where, whereLike, whereHas, orderBy (incl. Intl.Collator), groupBy, aggregates, updateOrCreate / firstOrCreate and 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

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Pinia ORM banner

npm version npm downloads Github Actions CI Coverage License

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 / firstOrCreate and 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 (or cd packages/pinia-orm && pnpm test:ui for the interactive UI)

Credits

Related projects

License

Made with ❤️

Published under MIT License.

Explorer des projets similaires

Chargement…