Socket
Socket
Sign inDemoInstall

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.2 to 1.2.3

5

dist/attributes.js

@@ -37,2 +37,3 @@ import { Model } from '@vuex-orm/core';

* Adds the property as an incremental field
* @deprecated Use `UidField` decorator instead.
*/

@@ -48,3 +49,3 @@ export function IncrementField() {

export function AttrField(defaultValue, mutator) {
return Field(Model.attr(defaultValue, mutator));
return Field(Model.attr(defaultValue || '', mutator));
}

@@ -65,3 +66,3 @@ /**

export function BooleanField(defaultValue, mutator) {
return Field(Model.boolean(defaultValue, mutator));
return Field(Model.boolean(defaultValue || false, mutator));
}

@@ -68,0 +69,0 @@ /**

4

dist/database.js

@@ -5,4 +5,4 @@ import VuexORM from '@vuex-orm/core';

}
ORMDatabase.install = function () {
return VuexORM.install(ORMDatabase._ormDatabase);
ORMDatabase.install = function (options) {
return VuexORM.install(ORMDatabase._ormDatabase, options);
};

@@ -9,0 +9,0 @@ ORMDatabase.registerEntity = function (model) {

@@ -1,2 +0,2 @@

import { Model, Attribute } from '@vuex-orm/core';
import { Attribute, Model } from '@vuex-orm/core';
import Mutator from '@vuex-orm/core/lib/attributes/contracts/Mutator';

@@ -17,3 +17,3 @@ /**

*/
export declare function StringField(defaultValue?: string, mutator?: Mutator<string | null>): (target: Object, propertyName: string | symbol) => void;
export declare function StringField(defaultValue?: string | null, mutator?: Mutator<string>): (target: Object, propertyName: string | symbol) => void;
/**

@@ -26,2 +26,3 @@ * Adds the property as a uid field

* Adds the property as an incremental field
* @deprecated Use `UidField` decorator instead.
*/

@@ -40,3 +41,3 @@ export declare function IncrementField(): (target: Object, propertyName: string | symbol) => void;

*/
export declare function NumberField(defaultValue?: number, mutator?: Mutator<number | null>): (target: Object, propertyName: string | symbol) => void;
export declare function NumberField(defaultValue?: number | null, mutator?: Mutator<number>): (target: Object, propertyName: string | symbol) => void;
/**

@@ -47,3 +48,3 @@ * Adds the property as a boolean typed field

*/
export declare function BooleanField(defaultValue: any, mutator?: Mutator<boolean | null>): (target: Object, propertyName: string | symbol) => void;
export declare function BooleanField(defaultValue?: boolean | null, mutator?: Mutator<boolean>): (target: Object, propertyName: string | symbol) => void;
/**

@@ -50,0 +51,0 @@ * Adds the property as a 'Has Many' relationship field

import { Model } from '@vuex-orm/core';
import { Plugin } from 'vuex';
import { Options } from '@vuex-orm/core/lib/store/install';
export declare class ORMDatabase {
private static _ormDatabase;
private static _installed;
static install(): Plugin<any>;
static install(options?: Options): Plugin<any>;
static registerEntity(model: typeof Model): void;
}
{
"name": "vuex-orm-decorators",
"version": "1.2.2",
"version": "1.2.3",
"description": "Simple Typescript decorators to improve the vuex-orm experience in Typescript by introducing typed property access.",

@@ -25,7 +25,7 @@ "main": "dist/index.js",

"devDependencies": {
"@vuex-orm/core": "^0.34.0",
"typescript": "^3.7.2",
"vue": "^2.6.10",
"vuex": "^3.1.2"
"@vuex-orm/core": "^0.36.3",
"typescript": "^3.9.7",
"vue": "^2.6.12",
"vuex": "^3.5.1"
}
}

@@ -8,5 +8,5 @@ # vuex-orm-decorators

Using the decorators allows better type safety in your projects by allowing you to create conventional Typescript properties, and anotate 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 documation 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.

@@ -52,2 +52,17 @@ ##### Contribute

### Nuxt.js
As Nuxt.js uses cjs modules you need to transpile the library. Add the following to the nuxt.config.js
```javascript
build: {
transpile: [
'vuex-orm-decorators'
]
}
```
If you want to register models automatically do not install vuex-orm database, just export plugin from store/index.js
```javascript
import { ORMDatabase } from 'vuex-orm-decorators'
export const plugins = [ORMDatabase.install()]
```
&nbsp;

@@ -62,10 +77,12 @@ # Usage

class User extends Model {
static entity = 'users';
static fields () {
return {
id: this.attr(undefined),
name: this.attr('')
};
}
static entity = 'users';
static fields() {
return {
id: this.attr(undefined),
name: this.attr('')
};
}
}

@@ -79,7 +96,6 @@ ```

@OrmModel('users')
class User extends Model{
class User extends Model {
@AttrField(undefined)
@AttrField()
public id!: number;

@@ -89,2 +105,3 @@

public name!: string;
}

@@ -101,7 +118,6 @@ ```

@OrmModel('users')
class User extends Model{
class User extends Model {
@AttrField(undefined)
@AttrField()
public id!: number;

@@ -112,5 +128,6 @@

public get lowerName(){
public get lowerName() {
return this.name.toLowerCase();
}
}

@@ -127,8 +144,7 @@ ```

@OrmModel('users')
class User extends Model{
class User extends Model {
@PrimaryKey()
@AttrField(undefined)
@AttrField()
public uuid!: number;

@@ -138,2 +154,3 @@

public name!: string;
}

@@ -155,10 +172,13 @@ ```

### Auto Increment
### ~~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.~~
### Primative Types
Use `UidField` decorator instead.
Like the vuex-orm library, you can create primative fields using the following decorators:
### Primitive Types
Like the vuex-orm library, you can create primitive fields using the following decorators:
1. ```@StringField``` creates a [string](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field

@@ -165,0 +185,0 @@ 2. ```@NumberField``` creates a [number](https://vuex-orm.github.io/vuex-orm/guide/model/defining-models.html#primitive-types) field

@@ -1,6 +0,4 @@

import { Model, Attribute } from '@vuex-orm/core';
import { Attribute, Model } from '@vuex-orm/core';
import Mutator from '@vuex-orm/core/lib/attributes/contracts/Mutator';
/**

@@ -31,4 +29,4 @@ * Sets the property as the primary key of the model

*/
export function StringField(defaultValue?: string, mutator?: Mutator<string | null>) {
return Field(Model.string(defaultValue || '', mutator));
export function StringField(defaultValue?: string | null, mutator?: Mutator<string>) {
return Field(Model.string(defaultValue || '', mutator as any));
}

@@ -46,2 +44,3 @@

* Adds the property as an incremental field
* @deprecated Use `UidField` decorator instead.
*/

@@ -58,3 +57,3 @@ export function IncrementField() {

export function AttrField(defaultValue?: any, mutator?: Mutator<any>) {
return Field(Model.attr(defaultValue, mutator));
return Field(Model.attr(defaultValue || '', mutator));
}

@@ -67,4 +66,4 @@

*/
export function NumberField(defaultValue?: number, mutator?: Mutator<number | null>) {
return Field(Model.number(defaultValue || 0, mutator));
export function NumberField(defaultValue?: number | null, mutator?: Mutator<number>) {
return Field(Model.number(defaultValue || 0, mutator as any));
}

@@ -77,4 +76,4 @@

*/
export function BooleanField(defaultValue: any, mutator?: Mutator<boolean | null>) {
return Field(Model.boolean(defaultValue, mutator));
export function BooleanField(defaultValue?: boolean | null, mutator?: Mutator<boolean>) {
return Field(Model.boolean(defaultValue || false, mutator as any));
}

@@ -81,0 +80,0 @@

@@ -1,5 +0,5 @@

import VuexORM, { Model, Database } from '@vuex-orm/core';
import VuexORM, { Model } from '@vuex-orm/core';
import { Plugin } from 'vuex';
import { Options } from '@vuex-orm/core/lib/store/install';
export class ORMDatabase {

@@ -10,4 +10,4 @@

public static install(): Plugin<any> {
return VuexORM.install(ORMDatabase._ormDatabase);
public static install(options?: Options): Plugin<any> {
return VuexORM.install(ORMDatabase._ormDatabase, options);
}

@@ -17,3 +17,3 @@

if (this._installed.indexOf(model) !== -1) {
console.error(`Unable to register entity ${model.name}. Entity already registered.`)
console.error(`Unable to register entity ${model.name}. Entity already registered.`);
return;

@@ -23,2 +23,2 @@ }

}
}
}

@@ -1,4 +0,1 @@

import { Attribute, Model } from '@vuex-orm/core';
import Mutator from '@vuex-orm/core/lib/attributes/contracts/Mutator';
export { OrmModel } from './model';

@@ -12,2 +9,2 @@ export { ORMDatabase } from './database';

PrimaryKey, StringField, UidField
} from './attributes';
} from './attributes';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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