Skip to content

Latest commit

 

History

History
258 lines (240 loc) · 11.1 KB

TODO.md

File metadata and controls

258 lines (240 loc) · 11.1 KB

To Do

Alpha

  • Decide if the types of the arrays must be passed with or without []
    • As they are the only type who need to be passed, will be passed without
  • Add Suffix
  • Add Prefix
  • Add extras field to @Entity and all @Column* decorators
  • Add Error Thrower
    • Export error thrower at src/index.ts
    • Return errors at src/decorators/column/helpers/get-type.ts
  • Create a Logger
  • Uncomment tests validation at .github/workflows/publish.yml
  • Join metadata manager to connection, so users can use multiple connections
    • Decorators stop using metadata manager and start using metadata again
    • Review all of the files, to look how the things are being done and what have to be changed
    • The metadata manager is created by the connection
  • Prefix and Suffix must be passed THE EXACT WAY that they are specified in the connection options, they MUST NOT be formatted
  • Change SubEntities
    • The sub-entities must be stored WITH THE ENTITIES, and not separately
    • To check if an entity has a table in the database, the metadata isSubEntity is used. If is a sub-entity, it DOESN'T has a table in the database
    • Update EntityManager.convertEntityToDatabase: If has the metadata isSubEntity, so the fields MUST NOT be affected by prefix or suffix
  • Add complex queries
    • Not
    • LessThan
    • LessThanOrEqual
    • MoreThan
    • MoreThanOrEqual
    • Like
    • Between
    • In
    • IsNull
  • Add Tests
    • Decorators
    • EntityManager
      • Initialization (verify if it is setting ENTITIES and SUB-ENTITIES correctly)
      • getAllEntitiesMetadata
      • getAllTablesMetadata
      • getEntityMetadata
      • getColumnMetadata
      • getEntityPrimaryColumns
      • convertEntityToDatabase
    • Error
    • Logger
    • Repository
      • Find Operators
        • LessThan
        • LessThanOrEqual
        • MoreThan
        • MoreThanOrEqual
        • Like
        • Between
        • In
        • IsNull
        • Not
    • Utils
      • formatNamingStrategy
      • MetadataUtil
        • isDefaultMetadataType
        • isCustomMetadataType
        • isMetadataType
        • hasEntityMetadata
        • getEntityMetadata
        • defineEntityMetadata
        • defineAllEntityMetadata
        • getAllEntityMetadata
        • addColumnMetadataToEntity
      • formatPrefix
      • formatSuffix
    • Validate if optional columns (ex: column?: string) get the correct tipping
  • Create method addColumnMetadataToEntity at MetadataUtil, and filter undefined fields before add the column
  • Add system to verify if the user has passed a custom entity / column name, and DON'T format it based on the naming pattern / prefix-suffix
  • Create method EntityManager.convertDatabaseToEntity
  • Uncomment tests validation at jest.config.js
  • Add pipeline step to check if mandatory files has changes
    • Mandatory files:
      • CHANGELOG.md
      • package.json
  • Add the concept of "auto-generated" (Code -> Database) columns
    • Determine if is auto-generated by the database or by the plugin
    • Add @PrimaryGeneratedColumn decorator
      • Make autoGenerateEntityToDatabase method generate values based on the column metadata
    • Add @SaveDateColumn decorator
    • Add @UpdateDateColumn decorator
    • Add @DeleteDateColumn decorator
    • Add validation at autoGenerateEntityToDatabase to validate if the column should be auto-generated based on event
  • Add Exist operator, to verify if a field doesn't exists
  • Review code to check if is possible to split params in injectables and not injectables
  • Unbind methods that receive this, change to receive the functions of the class instead, and make the methods PRIVATE
  • Fix build script
  • Add tests to src/lib/utils/validations
  • Add EntityManager.convertColumnsNames
    • Will convert a array of strings into an array of strings with the database columns manes
  • Add select option conversion at beforeFind
  • Add EntityManager.formatOrder
    • Will convert an object with columns order to the database names
  • Add order option conversion at beforeFind
  • Fix all after* commands to return the correct value
    • afterSave
    • afterInsert
    • afterUpdate
    • afterUpsert
  • Add before and after methods
    • save
    • insert
    • update
    • upsert
    • find
    • findOne
    • delete
    • softDelete
    • recover
    • count
    • performativeCount
  • Create a template repository "thoth-plugin"

General

  • Review column name converter
    • SubEntity columns also should be converted?
      • Yes, they will be converted, only the prefixes aren't will be applied
  • Add "comment" option to "@Column" decorator
    • Will receive a comment about the column
  • Add "enum" option to "@Column" decorator
    • Will receive a enum and get it's values
  • Add "defaultValue" option to "@Column" decorator
    • Will receive the default value of the column
  • Add @Index decorator
  • Add "index" to FindOptions
  • Add "databaseType" to ColumnOptions
  • Add "Save Operators"
    • Remove -> deletes a column from a record
    • Plus -> Sets the value of a column as itself + the value passed as param
    • Minus -> Sets the value of a column as itself - the value passed as param
    • Append -> Add element to the end of a list
    • Min -> Changes the value of the column ONLY IF it's greater than the value specified
    • Max -> Changes the value of the column ONLY IF it's lower than the value specified
    • IfNotExists -> Only sets the column if it NOT already exists
    • Pop -> Removes and item from a list
  • Change the way that prefix and suffix work
    • EntityToDatabase -> Will be applied BEFORE the naming strategy
    • DatabaseToEntity -> Will be applied AFTER the naming strategy
  • Make the @PrimaryColumn* decorators accept only string and number as types
  • Add entities auto-import from string path, like TypeORM
  • Edit the auto-generation method of primary columns
  • Add SubEntity decorator
    • Will replace @Entity({ isSubEntity: true }) to make things more explicity
    • [SOLVED] What if a entity be an entity and also a subEntity? If the entity is both an entity and sub-entity, you can use the @Entity decorator as always. Both types of entities are handled in the same way, with the only differece beign having a table in the database or not.
  • Refact "auto-generation"
    • Remember to remove the "todo" test
  • Add @CountUpdateColumn that receives NO PARAMS
    • Only accepts "number" type
    • This column will be auto-generated on update
    • The value of this column will be the SaveOperator Plus(1)
  • Refact @CountUpdateColumn to be @CountColumn
    • Will receive a parameter events, an array of events to increment the count
  • Add validation "cannot be array" and "must be array" to the getType helper
  • Add colors to the logs, like Nestjs Logger
  • Add @VersionColumn that receives the version (Ex: @VersionColumn("v2"))
    • Only accepts "string" type
    • This column will be auto-generated on save
  • Add @RunBefore
    • Will recieve 1 parameter (save, find, update, delete)
    • Will be aplied to entity methods
    • Will run before an event
    • The method will recieve 3 parameters
      • conditions
      • data
      • options
    • Try to make a Entity type, that ignores runBefore methods
  • Add @RunAfter
    • Will recieve 1 parameter (save, find, update, delete)
    • Will be aplied to entity methods
    • Will run after an event
    • The method will recieve 3 parameters
      • conditions
      • data
      • options
    • Try to make a Entity type, that ignores runAfter methods

Docs

  • Fix verify mandatory files workflow
  • Improve Documentation
    • Like TypeORM docs
    • Use Docusaurus
    • Give a bit of love to CONTRIBUTING.md
    • Add COMPLETE documentation about HOW to create a plugin
      • Include EVERY validation that need to be done
      • Include EVERY step IN ORDER that need to be made
    • Create a markdown table with ALL the features of the ORM, so the plugins can specify EVERY feature that they have implemented
    • Create tutorials
      • "how to work with multiple value types for the same field"
      • "how to work with the same table for multiple entities" / "how to work with a table that have multiple entities schemas"
      • "how to work with array columns that can have multiple types" (Ex: column: Array<Entity1 | Entity2>)

SQL

Requirements

CREATE TABLE bar (
    id SERIAL,
    bar_created_on ABSTIME,
    bar_deactivated_on ABSTIME,
    foo_id INTEGER NOT NULL,
    foo_created_on ABSTIME NOT NULL,
    FOREIGN KEY (foo_id, foo_created_on) REFERENCES foo (id, foo_created_on),
    PRIMARY KEY (id, bar_created_on)
);

Entity that can hold the foreign key

current target a third one
one to one x
one to one x
one to many x
many to one x
many to many x

Tasks

  • Add support to Enums (currently, it already works with enums, but it doesn't saves the enums values. The Column decorator need to be modified to accept an enum too, and use Object.values to get the VALUES of the array)
    • Add "enum" option to "@Column" decorator
      • Will receive an enum to get it's values
  • Add @OneToOne decorator
    • Entity Decorator
    • Used to specify that a table has a relation with another table
    • Metadata type: "ONE_TO_ONE" | "ONE_TO_MANY" | "MANY_TO_ONE" targetEntity: [Entity class] relationMap: { [current entity column]: [target entity column] }
  • Add @OneToMany decorator
  • Add @ManyToOne decorator
  • Add @ManyToMany decorator

CLI

  • Add "migrations"
    • Add a way to generate "tables" (Run a command that uses the plugin config to generate a new migration file based on the entities data)
    • This can be used for SQL and NoSql databases (Ex: PostgreSQL & Dynamo)

Discarded Ideas

  • Add @SecondaryColumn decorator (This will be used in cases like DynamoDB - sortKey)
    • extras field will be used
  • Maybe in the future accept more column type and handle the correspondent function automatically? Types like accept "bigint" as param for @Column, convert this automatically to Number, and store the "bigint" at the "extras" field, so relational databases can take more advantage of this package
    • No, the option "databaseType" was added to this purpose