Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

How to generate model classes from generated typescript types #94

Open
guntribam opened this issue Aug 31, 2020 · 5 comments
Open

How to generate model classes from generated typescript types #94

guntribam opened this issue Aug 31, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@guntribam
Copy link

First of all. Your product is amazing. Congratulations.

I need help understanding how can i use the generated code in Typescript to create my Model Classes.

I'll put an example right here:
ERD
This model create these two Typescript interfaces

export interface Conta {
  id: number;
  nome: string;
  idUsuario: number;
}
export interface Lancamento {
  id: number;
  valor: number;
  descricao: string | null;
  tipo: string;
  idConta: number;
}

But the model that i'm building is like this:

import { BaseModel, belongsTo, column, BelongsTo, hasMany, HasMany } from '@ioc:Adonis/Lucid/Orm'
import Lancamento from '../Lancamento'
import Usuario from 'App/Usuario/Usuario'

export default class Conta extends BaseModel {
  public static table = 'CONTA'

  @column({ isPrimary: true })
  id: number

  @column()
  nome: string

  @column({ columnName: 'idUsuario' })
  idUsuario: number

  @belongsTo(() => Usuario)
  usuario: BelongsTo<typeof Usuario>

  @hasMany(() => Lancamento, {foreignKey: 'idConta'})
  lancamentos: HasMany<typeof Lancamento>

}
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'

export default class Lancamento extends BaseModel{
  public static table = "LANCAMENTO"

  @column({ isPrimary: true })
  id: number

  @column()
  valor: number

  @column()
  descricao: string | null

  @column()
  tipo: string | null

  @column({ columnName: 'idConta' })
  idConta: number
  
}

How can i get the interfaces generated by the extension in order to create a class like these 2?

@guntribam
Copy link
Author

guntribam commented Aug 31, 2020

I closed by mistake. Please open this project for funding. In some months i'll be able to help you guys with some money. Please accept it. Your work is great

@guntribam guntribam reopened this Aug 31, 2020
@dineug
Copy link
Owner

dineug commented Aug 31, 2020

I think we need detailed settings for various needs.

Or maybe we should develop an expanded API so that we can easily participate.

Like highlightjs.

I'm focusing on SQL DDL parser right now.

I'll think about it when it's done.

Thanks for letting me know your use case.

If you need it right now, Reference

Request a PR.

@guntribam
Copy link
Author

I've never contributed to open source before, but i'll try to do something...

@guntribam
Copy link
Author

I'll just leave here the prototype of how this can be achieved with a new canvas in this extension using Mustache as template. @dineug what do you think?
Changes in Vuerd

@dineug
Copy link
Owner

dineug commented Sep 2, 2020

Because the existing editor data is large enough,
I think we need to externalize template data.

@dineug dineug added the enhancement New feature or request label Sep 5, 2020
This was referenced Sep 17, 2020
This was referenced Apr 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants