dynamoose/dynamoose

Plugin Support

Open

#851 opened on 2020年5月1日

GitHub で見る
 (11 comments) (0 reactions) (0 assignees)JavaScript (2,025 stars) (349 forks)batch import
help wantedtype:discussion

説明

Plugin Support

Overview

In v1 of Dynamoose we had beta support for plugins. This issue is to explore bringing them back and to discuss possible implementation options. I'm really looking for comments about this. What would you like to see in Dynamoose plugin support? What were your thoughts/feelings about v1 plugins? Do you have any suggestions about how to clean up the code, make it more DRY and improve it from v1 plugins?

Existing v1 Plugins

Although v2 plugins will have breaking changes. It is a goal to be able to support the use cases for these plugins from v1:

Goals

  • Have a cleaner, simpler, and DRYer implementation and API than v1
  • Have support for custom types (this is something that Mongoose does, where plugins can expose a type(s) and users can use that custom type(s) in their own schemas, however we did not do this in v1, would like to see this done in v2)
  • Better definition about what should be considered a plugin vs part of the core library

Challenges

https://github.com/dynamoose/dynamoose/blob/9e5fb1605e99da2d5550cfa896d224c09aaa3cc8/lib/Model.js#L618-L643

24 lines to support plugins in v1 for what should be a 1 line task. It adds a lot of bloat to Dynamoose. None of that code was DRY, and having to emit on everything felt really messy. I'm very against going back to that old way of doing it. Adding that much code and bloat just to support plugins does not seem worth it to me. I would love to support plugins tho. It just needs to be done in a way that is reasonable, clean, and elegant.

Kinda same thing with logging support in v2. We only log AWS requests and responses currently in v2. So 1 line of code became 4 because of logging support.

https://github.com/dynamoose/dynamoose/blob/ec9379affcd6f7a59509fcaf6ced680110001089/lib/aws/ddb/internal.ts#L29-L32

Which is one of the reasons why I haven't expanded the logging support very much in v2. I realize that there aren't too many good solutions to get around this stuff, but both of those are just so messy. If we are gonna add this to the library, I want it to be clean and elegant.

So really looking for advice, suggestions, and feedback here.

References

コントリビューターガイド

Plugin Support · dynamoose/dynamoose#851 | Good First Issue