maya icon indicating copy to clipboard operation
maya copied to clipboard

Universal model decorator

Open mackignacio opened this issue 4 years ago • 0 comments

📝 Description

To handle multiple database we must have a universal model decorator. This decorator creates an objects that maps all the fields and exposes and API for the Database class to consume. This way we will just write one model and it can be used by any database.

⚙️ Component

Suggested code sample

const schema = {
  name : {
     type: string | number | boolean | ObjectId | Date | Enum; // REQUIRED
     required: boolean; // DEFAULT false
     unique: boolean; // DEFAULT false
     ref: ObjectId; // OPTIONAL
     maxLength: number; // OPTIONAL
     minLength: number; // OPTIONAL
     validation: Array<Validation> // OPTIONAL
  }
};
@Model( "name-of-model" , schema );

📋 Todo:

  • [ ] Create a model decorator factory
  • [ ] Create an API for Database class to expose the model object
  • [ ] Create a list of models that can be called inside a service or controller
  • [ ] Able to define the model in app.module.ts
  • [ ] Model can be used by any ORM library

🔍 Additional Info

This feature is vital for the release of version 1.0.0.

mackignacio avatar Mar 18 '20 17:03 mackignacio