Git Product home page Git Product logo

dynamodels's People

Contributors

dependabot[bot] avatar marioarnt avatar sajidhamza9 avatar snyk-bot avatar thibaultruby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dynamodels's Issues

Provide batch write method

Currently there is no batch write method.
Provide an overlay over DocumentClient.batchWrite that automatically split array of operations in batch respecting the AWS limitations.

A single BatchWriteItem request can contain up to 25 write requests (PutItem or DeleteItem)

To perform a batch write operation using the AWS SDK DocumentClient v3, you can use the batchWrite method. This method allows you to perform batch write operations on one or more tables in a DynamoDB database.

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/Class/BatchWriteCommand/

The compatibility with autoCreatedAt and autoUpdatedAt must be maintained with this new method.

Prefix protected methods with trailing _

Breaking changes !

Would be great to prefix protected methods _save, _create etc...

The Model class is abstract and need to be subclassed, but now we can't create methods called get, save with a different signature which is annoying

Provide a getItem method

Dynamodels v1.3.3
Enhancement

We should be able to call a get-item method in addition of the save-item one.

Fix CI tests

CI tests are not passing in CI because of a dynamodb-local connection even if they're passing localy.

Run npm run test:ci

> [email protected] test:ci
> LOCAL_DYNAMODB_HOST=localhost LOCAL_DYNAMODB_PORT=8022 npx jest --runInBand --config jest.config.json --coverage --detectOpenHandles

Fatal: Cannot create table for tests UnrecognizedClientException: The Access Key ID or security token is invalid.
    at throwDefaultError (/home/runner/work/dynamodels/dynamodels/node_modules/@smithy/smithy-client/dist-cjs/default-error-handler.js:8:22)
    at /home/runner/work/dynamodels/dynamodels/node_modules/@smithy/smithy-client/dist-cjs/default-error-handler.js:18:39
    at de_CreateTableCommandError (/home/runner/work/dynamodels/dynamodels/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:6[4](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:5)2:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:9[5](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:6):5)
    at async /home/runner/work/dynamodels/dynamodels/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
    at async /home/runner/work/dynamodels/dynamodels/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20
    at async /home/runner/work/dynamodels/dynamodels/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:4[6](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:7)
    at async /home/runner/work/dynamodels/dynamodels/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:[7](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:8):26
    at async Promise.all (index 2)
    at async exports.default (/home/runner/work/dynamodels/dynamodels/test/hooks/setup.ts:6:9) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'd36d0eb5-a6c4-4f[8](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:9)8-aa43-e5dea31a1[9](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:10)f0',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  __type: 'com.amazonaws.dynamodb.v201208[10](https://github.com/neoxia/dynamodels/actions/runs/6233596966/job/17640767645?pr=278#step:7:11)#UnrecognizedClientException'

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Allow SSM parameter name as table name

Currently only a harcoded string is allowed as table name in Models definitons.

Add an option to source the table name from AWS Systems Manager (SSM) Parameter Store.

Instead of the table name, we pass a SSM ARN and the value is swapped on run-time.

Thus it would be possible to update the table name without redeployment (useful after a backup, for example).

export class MyModel extends Model<unknown> {
  tableName = 'arn:aws:ssm:<aws-region>:<aws-account-id>:database-name-prod';
}

The behavior to implement is the following:

  • Check if table name is a SSM ARN (using a regexp)
  • If not, use provided string as it
  • If it is a SSM parameter ARN, fetch its value at first request and cache this result for subsequent requests

Add an option on model construction to forbid scan

It would be good to have the ability to specify on model construction that we forbid scan.

class MyModel extends Model<unknown> {
   allowScan = false;
}

If you perform a Model.prototype.scan it will throw if allowScan === false

CreatedAt/updatedAt

It would be useful to have automatically generated fields createdAt and updatedAt that are kept up to date when entities are updated.

class MyModel extends Model<unknown> {
   autoCreatedAt = true; // false in super class
   autoUpdatedAt = true; // false in super class
}

The createdAt is set at the initial creation and remains unchanged. It is set only when using DocumentClient.create method. And the validity of the field is not maintained by dynamodels on DocumentClient.save.

Please make sure to update the updatedAt during subsequent calls to the DocumentClient.update and DocumentClient.save methods.

Searching into json nested attributes does not works

Affected version : v2.0.1

Current behavior:
When trying to use filter on nested attributes:

  const myModel = new MyModel(); // With any Dynamodels model
  const value = await myModel
    .query()
    .keys({
      pk: 'something',
    })
    .filter(attr('key.#key2').eq('something-to-match'))
    .execAll();

We get the following error:

ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#key1.#key2f1a48369fb1b4fbf98c2ec8893a95063"

When it should just returns the filtered list.

The issues seems to be related to ExpressionAttributeNames mapping that is like this :

ExpressionAttributeNames: {
    '#sk': 'sk',
    '#key1.#key2f1a48369fb1b4fbf98c2ec8893a95063': 'key1.#key2'
  }

When it should be like that:

ExpressionAttributeNames: {
    '#sk': 'sk',
    '#key12f1a48369fb1b4fbf98c2ec8893a95063' : 'key1',
    '#key2<some-other-uuid>: 'key2'
  }

Imho, we should just be able to type 'key1.key2.key3' and Dynamodels should parse this and understand that this is a nested attribute case and correctly fills the ExpressionAttributeNames.

Provide count method

Provide a method that returns the number of items in the table

public async count(exact?: boolean): Promise<number>

Use the describeTable API if exact is not specified.
The result will be returned quickly but is only refreshed every 6 hours.
Otherwise perform a full scan to get the exact count, which is time-consuming and not recommended

Some imports are not correctly exposed

Affected version : v2.0.1

Current behavior:
Two useful imports come from 'dynamodels/dist/src/filter-conditions':

  import { attr, not } from 'dynamodels/dist/src/filter-conditions';

We should just be able to imports them from 'dynamodels'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.