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 2.0.0-beta.2 to 2.0.0-beta.3

dist/plugins/Date/DateType.js

42

dist/attributes.js
import { Model } from '@vuex-orm/core';
const defaultValues = {
Attr: '',
Boolean: false,
String: '',
Number: 0,
};
/**

@@ -8,7 +14,14 @@ * Adds the property as a model field

const constructor = target.constructor;
const field = fieldType;
constructor._fields = Object.assign(constructor.fields(), constructor._fields);
if (!fieldType.mutator && fieldType.value === null) {
fieldType.isNullable = true;
if (field.mutator && field.value === null) {
field.value = defaultValues[field.constructor.name];
}
constructor._fields[propertyName] = fieldType;
if (field.value === undefined) {
field.value = defaultValues[field.constructor.name];
}
if (!field.mutator && field.value === null) {
field.isNullable = true;
}
constructor._fields[propertyName] = field;
constructor.fields = () => {

@@ -19,8 +32,2 @@ return Object.assign({}, constructor._fields);

}
function nullable(value, defaultValue) {
if (value === null) {
return null;
}
return value === undefined ? defaultValue : value;
}
/**

@@ -47,3 +54,3 @@ * Adds the property as the `primary key` of the model

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

@@ -54,3 +61,3 @@ /**

export function StringField(value, mutator) {
return Field(Model.string(nullable(value, ''), mutator));
return Field(Model.string(value, mutator));
}

@@ -61,9 +68,10 @@ /**

export function NumberField(value, mutator) {
return Field(Model.number(nullable(value, 0), mutator));
return Field(Model.number(value, mutator));
}
/**
* Adds the property as a `boolean` field
* Adds the property as a `date` field
*/
export function BooleanField(value, mutator) {
return Field(Model.boolean(nullable(value, false), mutator));
export function DateField(value, mutator) {
// @ts-expect-error use of Date plugin
return Field(Model.date(value, mutator));
}

@@ -73,4 +81,4 @@ /**

*/
export function DateField(value, mutator) {
return Field(Model.attr(nullable(value, null), mutator));
export function BooleanField(value, mutator) {
return Field(Model.boolean(value, mutator));
}

@@ -77,0 +85,0 @@ /**

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

import { Database, install } from '@vuex-orm/core';
import { Database, install, use } from '@vuex-orm/core';
import DatePlugin from '@/plugins/Date';
use(DatePlugin);
export class ORMDatabase {

@@ -3,0 +5,0 @@ static install(options) {

@@ -24,9 +24,9 @@ import { Model } from '@vuex-orm/core';

/**
* Adds the property as a `boolean` field
* Adds the property as a `date` field
*/
export declare function BooleanField(value?: boolean | null, mutator?: Mutator<boolean>): (target: Object, propertyName: string | symbol) => void;
export declare function DateField(value?: Date | null, mutator?: Mutator<Date>): (target: Object, propertyName: string | symbol) => void;
/**
* Adds the property as a `boolean` field
*/
export declare function DateField(value?: Date | string | null, mutator?: Mutator<Date | null>): (target: Object, propertyName: string | symbol) => void;
export declare function BooleanField(value?: boolean | null, mutator?: Mutator<boolean>): (target: Object, propertyName: string | symbol) => void;
/**

@@ -33,0 +33,0 @@ * Adds the property as a `Has One` relationship field

{
"name": "vuex-orm-decorators",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"description": "Simple Typescript decorators to improve the vuex-orm experience in Typescript by introducing typed property access.",

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

"scripts": {
"build": "yarn lint && yarn test && tsc --rootDir src",
"build": "yarn lint && yarn test && tsc --rootDir src && rm -rf dist/{plugins,types/plugins}",
"lint": "eslint . --ext .ts",

@@ -12,0 +12,0 @@ "test": "jest",

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