Git Product home page Git Product logo

vuex-orm-decorators's Introduction

Hi there ๐Ÿ‘‹

vuex-orm-decorators's People

Contributors

armaaar avatar dmitryrazinkov avatar eeriksp avatar sarim avatar scotley avatar tibianmod avatar whax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vuex-orm-decorators's Issues

Error while compiling on Windows

ERROR Failed to compile with 1 errors

This relative module was not found:

  • ./model in ./node_modules/vuex-orm-decorators/dist/index.js

The dist folder contains both Model.js and model.js (and map and ts files also) and this messes up (case insensitive) Windows.

Cannot read property 'localKey' of undefined

I recently switched to using vuex-orm-decorators from the normal way. Now, I'm getting a Cannot read property 'localKey' of undefined. Any ideas? I debugged the setup and thought this screenshot below might be helpful. It shows some of the classes not being imported correctly. This might not be a vuex-orm-decorators problem but do you have any suggestions for why this might be happening?

Stack Trace:

vuex-orm.esm.js:2592 Uncaught TypeError: Cannot read property 'localKey' of undefined
    at Function.Model.belongsTo (vuex-orm.esm.js:2592)
    at BelongsToField (attributes.js:79)
    at eval (appUser.ts:20)
    at Module../src/store/models/appUser.ts (app.js:1608)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (role.ts:9)
    at Module../src/store/models/role.ts (app.js:1656)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)

appUser.ts

import { Model } from "@vuex-orm/core";
import {
  AttrField,
  BelongsToField,
  BelongsToManyField,
  OrmModel,
  PrimaryKey,
} from "vuex-orm-decorators";
import { Role } from "./role";
import { AppUserRole } from "./appUserRole";
import { App } from "./app";
import { User } from "./user";

@OrmModel("appUsers")
export class AppUser extends Model {
  @PrimaryKey()
  @AttrField(null)
  id!: number;
  @BelongsToField(App, "appId")
  app!: App;
  @AttrField(null)
  appId!: number;
  @AttrField(null)
  createdDate!: Date;
  @BelongsToManyField(Role, AppUserRole, "appUserId", "roleId")
  roles!: Role[];
  @AttrField(null)
  updatedDate!: Date;
  @BelongsToField(User, "userId")
  user!: User;
  @AttrField(null)
  userId!: number;
}

app.ts

import { Model } from "@vuex-orm/core";
import {
  AttrField,
  HasManyField,
  OrmModel,
  PrimaryKey,
} from "vuex-orm-decorators";
import { AppRequest } from "./appRequest";
import { AppUser } from "./appUser";
import { Role } from "./role";

@OrmModel("apps")
export class App extends Model {
  @PrimaryKey()
  @AttrField(null)
  id!: number;
  @HasManyField(AppRequest, "appId")
  appRequests!: AppRequest[];
  @HasManyField(AppUser, "appId")
  appUsers!: AppUser[];
  @AttrField("")
  description!: string;
  @AttrField("")
  longName!: string;
  @HasManyField(AppUser, "appId")
  roles!: Role[];
  @AttrField("")
  shortName!: string;
}

LocalKeyError

definition of AttrField wrong

Hi,

the decorator for AttrField produces a string field. From attributes.ts, line 46:

export function AttrField(defaultValue?: any) {
    return Field(Model.string(defaultValue));
}

I suggest this should be: Model.attr(defaultValue).

best regards,
Arno

May I have discussion about the repo?

Hi! I'm the author of Vuex ORM and just started implementing our own decorator feature. It's at https://github.com/vuex-orm/vuex-orm-decorator.

Then, I found out this repo! Sorry I didn't know. It looks wonderful! I would really love to have decorator feature in the Vuex ORM family.

If I may, I would like to invite you to the discussion for the repo. At least, credit you for this wonderful work.

If it sounds good to you, please ping me at Vuex ORM Slack channel! Or email me! ๐Ÿค

Single Table Inheritance

I have 2 models; Setting and FooSetting. According to the docs I setup Single Table Inheritance the following way.

import { OrmModel, StringField } from 'vuex-orm-decorators';
import Setting from '@/models/Setting';

@OrmModel('foo-settings', 'settings', {
    FOO: FooSetting,
    GENERAL: Setting,
})
export class FooSetting extends Setting {
    @StringField('')
    test!: string;
}

export default FooSetting;

I get the following warning within the console.

[Vuex ORM] Model `FooSetting` extends `Setting` which doesn't overwrite Model.types(). You will not be able to use type mapping.

Am I implementing this correctly?

UID Type missing

class User extends Model {
  static entity = 'users'

  static fields () {
    return {
      id: this.uid(() => uuid())
    }
  }
}

Seems like there is no UidField decorator?

The npm-publish started failing

Hi @Scotley,

the publishing jobs started to fail with the following error..

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/vuex-orm-decorators - Not found
npm ERR! 404 
npm ERR! 404  '[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
  • Probably you need to re authenticate the package on npm and re run the following job please to make sure is working again.
  • Note: The workflow file is 100% correct, is not there the problem
    I have already published 4 releases with this workflow

Please take care of it @Scotley :)

TypeError: this.types is not a function

When I try to insert into the DB, I get the error TypeError: this.types is not a function

Entity looks like this

import { Model } from "@vuex-orm/core";
import { NumberField, OrmModel, StringField } from "vuex-orm-decorators";

@OrmModel("races")
export default class Race extends Model {
  @NumberField()
  public ID!: number;

  @StringField()
  public Name!: string;
}

store looks like this:

import Vue from "vue";
import Vuex from "vuex";
import { ORMDatabase } from "vuex-orm-decorators";

Vue.use(Vuex);

export default new Vuex.Store({
  .
  .
  .
  plugins: [ORMDatabase.install()]
});

Also, maybe this is a clue.... in Vuex-Orm, this.setters is returning a value, but this.setters('all') is returning undefined.

/**
 * Get all records.
 */
Model.all = function () {
   return this.getters('all')();
};

From seeing the undefined basic fields and functions, it seems like the vuex-orm database isn't getting set up correctly. Any ideas?

I also posted this on StackOverflow to see if other people have ideas.
https://stackoverflow.com/questions/59020879/typeerror-this-types-is-not-a-function-when-using-vuex-orm-decorators

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.