Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"hasOne" relation must be an object #69

Closed
ottojimb opened this issue Jul 31, 2016 · 1 comment
Closed

"hasOne" relation must be an object #69

ottojimb opened this issue Jul 31, 2016 · 1 comment
Assignees
Milestone

Comments

@ottojimb
Copy link

When the model is declared using relations as "hasOne" the resultant property must be an object. At this moment the class is returning an Array. It's possible?

Example ("user" model with passport):

{
  "name": "user",
  "plural": "users",
  "base": "User",
  "idInjection": true,
...
  "relations": {
    "profile": {
      "type": "hasOne",
      "model": "Profile"
    },
...
}

The generated class is:

/* tslint:disable */
import {
  Profile,
  AccessToken,
  UserIdentity,
  UserCredential,
  Question
} from '../index';

export interface UserInterface {

  realm?: string;    
  username?: string;    
...
  id?: number;  
  profile?: Array<Profile>; //must be profile?: Profile;
  accessTokens?: Array<AccessToken>;
...
}

export class User implements UserInterface {

  realm: string;  
  username: string;  
...  
  id: number;  
  profile: Array<Profile>; //must be profile: Profile;
  accessTokens: Array<AccessToken>;
...
  constructor(instance?: User) {
    Object.assign(this, instance);
  }
}

Thank you!

@jonathan-casarrubias
Copy link
Collaborator

jonathan-casarrubias commented Aug 2, 2016

@ottojimb thank you for reporting.

This issue is fixed will be released in RC7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants