Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Design a new feature, JsonSelectBuilder #23

Closed
samchon opened this issue Sep 9, 2021 · 1 comment
Closed

Design a new feature, JsonSelectBuilder #23

samchon opened this issue Sep 9, 2021 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers

Comments

@samchon
Copy link
Owner

samchon commented Sep 9, 2021

Design a new class JsonSelectBuilder who can convert ORM Model class to a specified JSON data. When the JsonSelectBuilder converting ORM Model to the JSON data, it automatically performs the app joining (by the AppJoinBuilder - #15). The automatic app joining would find the best app joi plan by itself.

@samchon samchon added the enhancement New feature or request label Sep 9, 2021
@samchon samchon self-assigned this Sep 9, 2021
@samchon
Copy link
Owner Author

samchon commented Sep 10, 2021

The design would be like below:

export class JsonSelectBuilder<
        Mine extends object, 
        InputT extends JsonSelectBuilder.Input<Mine>,
        Destination = JsonSelectBuilder.Output<Mine, InputT>>
{
    public constructor(mine: Creator<Mine>, input: InputT);
    public constructor
        (
            mine: Creator<Mine>, 
            input: InputT, 
            mapper: JsonSelectBuilder.OutputMapper<Mine, InputT, Destination>
        );

    public getOne(record: Mine): Promise<Destination>;
    public getMany(records: Mine[]): Promise<Destination[]>;
}
export namespace JsonSelectBuilder
{
    export type Input<Mine extends object> = OmitNever<
    {
        // key: list up Mine fields and relationship accessors
        // value: DEFAULT, Closure and hierarchical JsonSelectBuilder
    }>;

    export type Output<Mine extends object, InputT extends Input<Mine>> = OmitNever<
    {
        // key: key of InputT
        // value: JSON data after conversion
    }>;

    export type OutputMapper<Mine extends object, InputT extends Input<Mine>, Destination> 
        = (output: Output<Mine, InputT>, index: number, array: Output<Mine, InputT>[]) => Destination;
}

@samchon samchon added the documentation Improvements or additions to documentation label Sep 10, 2021
@samchon samchon changed the title Design a new feature, JsonQueryBuilder Design a new feature, JsonSelectBuilder Sep 10, 2021
@samchon samchon added the good first issue Good for newcomers label Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant