Code Monkey home page Code Monkey logo

sjs-base-model's People

Contributors

ccheney avatar codebelt avatar dependabot[bot] 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  avatar

Watchers

 avatar  avatar  avatar

sjs-base-model's Issues

Parse response data to model does not work with an object

Hey :)

I would like to parse the following response into appropriate models:

message: "success"
token: "xxx"
authUser: {id: "1", status: 1, email: "xxx",…}
models: {
    App: [{id: "1", name: "x1"},{id: "2", name: "x2"}]
    Location: [{id: "1", name: "y1"},{id: "2", name: "y2"}]
    Project: [{id: "1", name: "z1"},{id: "2", name: "z2"}]
}

My response model looks like this:

export default class AuthenticationResponseModel extends BaseModel {
  public readonly message: string = '';
  public readonly token: string | undefined = undefined;
  public readonly authUser: AuthUserModel = AuthUserModel as any;
  public readonly models: {
    App: AppModel[];
  } = { App: [AppModel as any] };

...

But if I take for example "App" out of the object and move it into the "root - level" it works exactly the same as with the "AuthUserModel".

public readonly App: AppModel[] = [AppModel as any];

Is this feature not supported or is something wrong in my code?

If this is not supported could you add this?

Thanks already for the help :)

Issue In 'Data' Constructor

hi,

i have structure data :

import { BaseModel } from 'sjs-base-model';
import  MetricsModel from './MetricsModel ';

export default class MetricsEnvelope extends BaseModel {
  public readonly totalRows: number = 0;
  public readonly data: MetricsModel[] = [];

  constructor(data: Partial<MetricsEnvelope >) {
    super();
    this.update(data);
  }
}

but an error appears in the constructor 'data'.
is there any other solution, besides change the API

thank's

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.