Skip to content
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

Merged
merged 6 commits into from
Feb 15, 2024

Conversation

SajidHamza9
Copy link
Contributor

No description provided.

Copy link
Contributor

@MarioArnt MarioArnt left a 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",
Copy link
Contributor

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

@@ -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>> {
Copy link
Contributor

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;
Copy link
Contributor

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 💯

@SajidHamza9 SajidHamza9 marked this pull request as ready for review January 24, 2024 13:10
Copy link
Contributor

@MarioArnt MarioArnt left a 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.

@MarioArnt MarioArnt merged commit 48926f6 into neoxia:main Feb 15, 2024
4 checks passed
@MarioArnt
Copy link
Contributor

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants