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.1.4 to 1.1.5

11

dist/model.js

@@ -6,10 +6,19 @@ import { ORMDatabase } from './database';

*/
export function OrmModel(entityName, parentEntity) {
export function OrmModel(entityName, parentEntity, types, typeKey) {
return function (constructor) {
var model = constructor;
// Set the entity name on the model constructor
constructor.entity = entityName;
// Set the parent entity name on the model constructo (if present)
if (parentEntity) {
constructor.baseEntity = parentEntity;
}
// Seup the types and descriminator (if set)
constructor.types = types;
if (types && typeKey) {
constructor.typeKey = typeKey;
}
// Add the fields generated by tha attribute decorators
constructor.fields = function () { return constructor._fields || {}; };
// Register the entity in the database
ORMDatabase.registerEntity(constructor);

@@ -16,0 +25,0 @@ return constructor;

5

dist/types/model.d.ts

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

import { Model } from '@vuex-orm/core';
/**

@@ -5,2 +6,4 @@ * Creates an vuex-orm Model

*/
export declare function OrmModel(entityName: string, parentEntity?: string): <Model_1 extends Function>(constructor: Model_1) => void | Model_1;
export declare function OrmModel(entityName: string, parentEntity?: string, types?: {
[key: string]: Model;
}, typeKey?: string): <Model_1 extends Function>(constructor: Model_1) => void | Model_1;
{
"name": "vuex-orm-decorators",
"version": "1.1.4",
"version": "1.1.5",
"description": "Simple Typescript decorators to improve the vuex-orm experience in Typescript by introducing typed property access.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -134,2 +134,6 @@ # vuex-orm-decorators

### Single Table Inheritance
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. To use a discriminator field the third and fourth arguments provide the type mapping and property name overrides.
### Generic Types

@@ -136,0 +140,0 @@

@@ -8,10 +8,20 @@ import { Model } from '@vuex-orm/core';

*/
export function OrmModel(entityName: string, parentEntity?: string) {
export function OrmModel(entityName: string, parentEntity?: string, types?: { [key: string]: Model }, typeKey?: string) {
return function <Model extends Function>(constructor: Model): Model | void {
const model: Function = constructor;
// Set the entity name on the model constructor
(constructor as any).entity = entityName;
// Set the parent entity name on the model constructo (if present)
if (parentEntity) { (constructor as any).baseEntity = parentEntity; }
// Seup the types and descriminator (if set)
(constructor as any).types = types;
if (types && typeKey) { (constructor as any).typeKey = typeKey; }
// Add the fields generated by tha attribute decorators
(constructor as any).fields = () => (constructor as any)._fields || {};
// Register the entity in the database
ORMDatabase.registerEntity(constructor as unknown as typeof Model);

@@ -18,0 +28,0 @@

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