Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex-orm-decorators

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex-orm-decorators - npm Package Compare versions

Comparing version 1.2.5 to 1.2.6

26

package.json
{
"name": "vuex-orm-decorators",
"version": "1.2.5",
"version": "1.2.6",
"description": "Simple Typescript decorators to improve the vuex-orm experience in Typescript by introducing typed property access.",

@@ -9,28 +9,24 @@ "main": "dist/index.js",

"scripts": {
"build": "tsc"
"build": "tsc --rootDir src"
},
"keywords": [
"vue",
"vuex",
"vuex-orm",
"typescript",
"decorators",
"ES2015",
"ES2016",
"ES2017",
"ES2018",
"ES2019",
"ES2020",
"ESNext"
"ES2015"
],
"repository": {
"type": "git",
"url": "git+https://github.com/scotley/vuex-orm-decorators.git"
"url": "git+https://github.com/TiBianMod/vuex-orm-decorators.git"
},
"author": "Scotley <scott@inspireweb.co.nz>",
"author": "TiBianMod <tibianmod@gmail.com>",
"license": "MIT",
"devDependencies": {
"@vuex-orm/core": "^0.36.3",
"typescript": "^4.0.3",
"vue": "^2.6.12",
"vuex": "^3.5.1"
"@vuex-orm/core": "^0.36",
"typescript": "^4.1",
"vue": "^2.6",
"vuex": "^3.6"
}
}
# vuex-orm-decorators
Decorator Syntax for Vuex ORM for better type safety and a better experience.
![NPM](https://img.shields.io/npm/l/vuex-orm-decorators.svg) ![npm bundle size](https://img.shields.io/bundlephobia/min/vuex-orm-decorators.svg) ![GitHub issues](https://img.shields.io/github/issues/scotley/vuex-orm-decorators.svg) ![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/scotley/vuex-orm-decorators.svg) ![](https://img.shields.io/badge/types-Typescript-blue.svg)
![NPM](https://img.shields.io/npm/l/vuex-orm-decorators.svg) ![npm bundle size](https://img.shields.io/bundlephobia/min/vuex-orm-decorators.svg) ![GitHub issues](https://img.shields.io/github/issues/TiBianMod/vuex-orm-decorators.svg) ![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/TiBianMod/vuex-orm-decorators.svg) ![](https://img.shields.io/badge/types-Typescript-blue.svg)
Typescript Decorators to simplify vuex-orm integration in typescript projects. If you are using the [vue-module-decorators](https://github.com/championswimmer/vuex-module-decorators) or [vue-property-decorator](https://github.com/kaorun343/vue-property-decorator) packages then this will allow you to use the vuex-orm plugin in the same way.
Typescript Decorators to simplify vuex-orm integration in typescript projects. If you are using
the [vue-module-decorators](https://github.com/championswimmer/vuex-module-decorators)
or [vue-property-decorator](https://github.com/kaorun343/vue-property-decorator) packages then this will allow you to
use the vuex-orm plugin in the same way.
Using the decorators allows better type safety in your projects by allowing you to create conventional Typescript properties, and annotate them as fields for a better experience. Intellisense in Visual Studio Code just works with the annotations, where it doesn't in the vanilla plugin without boilerplate.
Using the decorators allows better type safety in your projects by allowing you to create conventional Typescript
properties, and annotate them as fields for a better experience. Intellisense in Visual Studio Code just works with the
annotations, where it doesn't in the vanilla plugin without boilerplate.
This documentation isn't supposed to be a replacement for the vuex-orm documentation, if you are unfamiliar with the concepts of vuex-orm then check out their documentation: https://vuex-orm.github.io/vuex-orm/guide/prologue/what-is-vuex-orm.html. I have linked to relevant guide pages in their documentation throughout this documentation.
This documentation isn't supposed to be a replacement for the vuex-orm documentation, if you are unfamiliar with the
concepts of vuex-orm then check out their
documentation: https://vuex-orm.github.io/vuex-orm/guide/prologue/what-is-vuex-orm.html. I have linked to relevant guide
pages in their documentation throughout this documentation.

@@ -28,3 +37,4 @@ ##### Contribute

Models can automatically register themselves in the database. To do so, instead of installing the vuex-orm database, install the wrapper provided by this library as follows:
Models can automatically register themselves in the database. To do so, instead of installing the vuex-orm database,
install the wrapper provided by this library as follows:

@@ -45,4 +55,4 @@ ```typescript

When you use a model it registers itself in the database automatically if it has not already.
If you do not want auto registered models, simply install the vanilla database and register them as you would normally.
When you use a model it registers itself in the database automatically if it has not already. If you do not want auto
registered models, simply install the vanilla database and register them as you would normally.

@@ -87,3 +97,3 @@ ### Typescript

static entity = 'users';
static fields() {

@@ -99,3 +109,5 @@ return {

The defined fields don't gain type checking by Typescript in this way because they are never defined as properties of the model class. With this decorator library though it allows you to write the same in the following way to achieve type checking on your queried models:
The defined fields don't gain type checking by Typescript in this way because they are never defined as properties of
the model class. With this decorator library though it allows you to write the same in the following way to achieve type
checking on your queried models:

@@ -140,3 +152,4 @@ ```typescript

You can pass a closure to the 2nd argument of `@AttrField`, `@StringField`, `@NumberField`, and `@BooleanField` decorator. The closure takes the corresponding value as an argument, and you can modify the value however you want:
You can pass a closure to the 2nd argument of `@AttrField`, `@StringField`, `@NumberField`, and `@BooleanField`
decorator. The closure takes the corresponding value as an argument, and you can modify the value however you want:

@@ -159,3 +172,5 @@ ```typescript

Rather than setting a [primary key](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primary-key) by setting the static property `primaryKey` with the magic string name of the property you want to be the primary key, you can simply annotate the property with the `@PrimaryKey` decorator as follows:
Rather than setting a [primary key](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primary-key) by
setting the static property `primaryKey` with the magic string name of the property you want to be the primary key, you
can simply annotate the property with the `@PrimaryKey` decorator as follows:

@@ -181,3 +196,4 @@ ```typescript

If your model extends a base model, then STI inheritance needs to be used. The base entity name needs to be provided as the second argument to the ORMModel decorator and as third argument provide the discriminator fields:
If your model extends a base model, then STI inheritance needs to be used. The base entity name needs to be provided as
the second argument to the ORMModel decorator and as third argument provide the discriminator fields:

@@ -259,11 +275,16 @@ > Person : Base Entity

You can create the generic [attr field](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#generic-types) type using the `@AttrField` decorator.
You can create the
generic [attr field](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#generic-types) type using
the `@AttrField` decorator.
### Uid
To create [uid field](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#uid-type) which use the `@UidField` decorator.
To create [uid field](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#uid-type) which use
the `@UidField` decorator.
### ~~Auto Increment~~ (deprecated)
~~To create auto [increment fields](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#auto-increment-type) which use the `@Increment` decorator.~~
~~To create
auto [increment fields](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#auto-increment-type) which
use the `@Increment` decorator.~~

@@ -276,20 +297,42 @@ **Use `UidField` decorator instead.**

1. `@StringField` creates a [string](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field
2. `@NumberField` creates a [number](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field
3. `@BooleanField` creates a [boolean](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field
1. `@StringField` creates
a [string](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field
2. `@NumberField` creates
a [number](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field
3. `@BooleanField` creates
a [boolean](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field
### Creating Relationships
You can create all relationships defined in the vuex-orm library. All the relationship decorators take the exact same arguments as the vanilla vuex-orm library static functions.
You can create all relationships defined in the vuex-orm library. All the relationship decorators take the exact same
arguments as the vanilla vuex-orm library static functions.
1. `@HasManyField` creates a [HasMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-many) relationship field
2. `@HasOneField` creates a [HasOne](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one) relationship field
3. `@BelongsToField` creates an inverse [HasOne](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-inverse) relationship field
4. `@HasManyByField` creates a [HasManyBy](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#has-many-by) relationship field
5. `@HasManyThroughField` creates a [HasManyThrough](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#has-many-through) relationship field
6. `@BelongsToManyField` creates a [BelongsToMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#many-to-many) relationship field
7. `@MorphToField` creates a [MorphTo](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-polymorphic) relationship field
8. `@MorphOneField` creates a [MorphOne](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-polymorphic) relationship field
9. `@MorphManyField` creates a [MorphMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-polymorphic) relationship field
10. `@MorphToManyField` creates a [MorphToMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#many-to-many-polymorphic) relationship field
11. `@MorphedByManyField` creates a [MorphedByMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#defining-the-inverse-of-the-relationship-2) relationship field
1. `@HasManyField` creates a [HasMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-many)
relationship field
2. `@HasOneField` creates a [HasOne](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one)
relationship field
3. `@BelongsToField` creates an
inverse [HasOne](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-inverse) relationship
field
4. `@HasManyByField` creates
a [HasManyBy](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#has-many-by) relationship field
5. `@HasManyThroughField` creates
a [HasManyThrough](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#has-many-through) relationship
field
6. `@BelongsToManyField` creates
a [BelongsToMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#many-to-many) relationship field
7. `@MorphToField` creates
a [MorphTo](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-polymorphic) relationship
field
8. `@MorphOneField` creates
a [MorphOne](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-polymorphic) relationship
field
9. `@MorphManyField` creates
a [MorphMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#one-to-one-polymorphic) relationship
field
10. `@MorphToManyField` creates
a [MorphToMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#many-to-many-polymorphic)
relationship field
11. `@MorphedByManyField` creates
a [MorphedByMany](https://vuex-orm.github.io/vuex-orm/guide/model/relationships.html#defining-the-inverse-of-the-relationship-2)
relationship field

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc