-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Model): fetch tableName from (SSM) Parameter Store #291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Althrough tableName became now a possible Promise, we do not need to change public API here.
It would need a major release and rewrite A LOT of tests.
Have a look on PR #288 , the implementation is non-breaking and test are passing.
Maybe you can merge both of PRs good ideas: decarator-style and defer-resolve table name in query and scan.
tsconfig.json
Outdated
@@ -4,7 +4,7 @@ | |||
"rootDir": ".", | |||
"outDir": "./dist", | |||
"moduleResolution": "node", | |||
"module": "commonjs", | |||
"module": "ES2022", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to keep support of previous NodeJS versions, please revert to CommonJS
src/base-model.ts
Outdated
@@ -371,13 +414,13 @@ export default abstract class Model<T> { | |||
* @param options: Additional options supported by AWS document client. | |||
* @returns The scanned items (in the 1MB single scan operation limit) and the last evaluated key | |||
*/ | |||
public scan(options?: Partial<ScanCommandInput>): Scan<T> { | |||
public async scan(options?: Partial<ScanCommandInput>): Promise<Scan<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For backward compatibility reason we do not want to change public API and make scan
and query
method async.
Solution here is to leave TableName empty and resolve it when async method count
, exec
or execAll
are called.
protected tableName: string | undefined; | ||
|
||
@SSMParam | ||
protected tableName: string | Promise<string | undefined> | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use case for a decorator 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done !
Almost good for me 👍
I'm just asking one more thing:
Can you update README.md (first section) and mention this is now possible to load table name from SSM providing a code example.
108a53b
to
639d2e2
Compare
🎉 This PR is included in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.