Code Monkey home page Code Monkey logo

beyonce's People

Contributors

blimmer avatar dduugg avatar dependabot[bot] avatar gbryan avatar hsops avatar jcarver989 avatar joshc-hh avatar kedskeds avatar teeeteee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beyonce's Issues

Using Beyonce with Dataloader

I am using dataloader and I want to keep the type checking which Dataloader does support, that's why I find it it useful to export the keys types.

Also the returned value of the batchGet function is like so:

    batchGet<T extends PartitionAndSortKey<TaggedModel>>(params: {
        keys: T[];
        consistentRead?: boolean;
    }): Promise<GroupedModels<ExtractKeyType<T>>>;

Dataloader expects an array of Promises which makes it incompatible:
DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>

Update Item

Yesterday I realised that there is no update Item, and trying to implement it myself was not straight forward, especially the conditional updates and the nested fields when you have lists and maps inside your model. On the same note as the Put ReturnValue, having the option to get the updated fields is also good.

I know you are pretty responsive and quick to add these, I realise that this feature may be the trickiest until now, Let me know if you wanna discuss it here, may be I'll make a PR.

For now I just exported the DocumentClient and made a plain update myself just to not get stuck.

beyonce.batchWriteWithTransaction with Updates

Is there a way to do batch write with updates, puts and deletes ?
I think I red on the doc that conditional updates are not yet possible to ?!

Right now I am using the dynamodb client to make something like this work :

client.transactWrite({
    TransactItems : [
        {
            "Put": {
                "TableName": `${process.env.DATA_TABLE}`,
                "Item": {
                    "pk": {"S": `${BeginsWith.User}-${userId}`},
                    "sk": {"S": `${BeginsWith.Friend}-${firendId}`},
                    "followedUser": {"S": userId},
                    "followingUser": {"S": firendId},
                    "timestamp": {"S": +new Date},
                },
                "ConditionExpression": "attribute_not_exists(sk)",
                "ReturnValuesOnConditionCheckFailure": "ALL_OLD",
            }
        },
        {
            "Update": {
                "TableName": `${process.env.DATA_TABLE}`,
                "Key": {"pk": {"S": `${BeginsWith.User}-${firendId}`}, "sk": {"S": `${BeginsWith.User}-${firendId}`}},
                "UpdateExpression": "SET followers = followers + :i",
                "ExpressionAttributeValues": {":i": {"N": "1"}},
                "ReturnValuesOnConditionCheckFailure": "ALL_OLD",
            }
        },
        {
            "Update": {
                "TableName": `${process.env.DATA_TABLE}`,
                "Key": {"pk": {"S": `${BeginsWith.User}-${userId}`}, "sk": {"S": `${BeginsWith.User}-${userId}`}},
                "UpdateExpression": "SET following = following + :i",
                "ExpressionAttributeValues": {":i": {"N": "1"}},
                "ReturnValuesOnConditionCheckFailure": "ALL_OLD",
            }
        },
    ]
})

Thank you so much again for this library, Beyonce rocks !

This is gold ! thank you for doing this, except the YAML part though.

I made my own contraption to do the same thing same table, but multiple types, I am using graphql, so the typescript classes are part of the entire app.

Is there a technical limitation why you went with the yaml model generation ? instead of typescript decorators ?

Again thank you so much for this

Unit test suite is failing

I was going to rework this project to use CircleCI instead of CodeShip, but the test suite is falling locally, as well as in CI.

The jest-dynamodb package is failing with this issue: shelfio/jest-dynamodb#212. But it's fairly out-of-date, so I couldn't easily try the workaround described in that issue.

I also tried migrating to https://github.com/freshollie/jest-dynalite, but was running into issues with that, as well:

 FAIL  src/test/dynamo/Beyonce.test.ts
  ● Beyonce › should put and delete in the same transaction

    Failed: [UnknownOperationException: null]

      111 |   })
      112 |
    > 113 |   it("should put and delete in the same transaction", async () => {
          |   ^
      114 |     await testPutAndDeleteItemInTransaction()
      115 |   })
      116 |

      at Env.it (node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:95:24)
      at Suite.<anonymous> (src/test/dynamo/Beyonce.test.ts:113:3)
      at Object.<anonymous> (src/test/dynamo/Beyonce.test.ts:18:1)

Querying for a specific model type should return an empty list if no records matches

Hey Joshua,

I am opening new issues for tracking and to avoid that the other threads gets too long.
This query return undefined when there are no records for Book model.

import { BookModel } from "generated/models"

// Get all Books for an Author
const results = await beyonce
  .query(BookModel.partitionKey({ authorId: "1" }))
  .exec() // returns { Book: Book[] }

It would be best to return an empty array, since this is a Query(N) and not a Get(1).

There is no need for putting data type while querying to dynamoDb

I made a query using a partionkey, the constructed json query outputted by the beautiful Beyoncé is like this:

[AWS dynamodb 200 0.007s 0 retries] query({ TableName: 'test-dev',
  KeyConditionExpression: '#pk = :pk',
  ExpressionAttributeNames: { '#pk': 'pk' },
  ExpressionAttributeValues: { ':pk': { S: 'USR-test' } } })

Why not just put ExpressionAttributeValues: { ':pk': 'USR-test' } without the type ?

Delimiter is hardcoded to "-" value

The current implementation of library does not support any delimiter other than "-".
It would be nice to make it dynamic and configurable in the yaml to support already created tables.
for eg. # (pound sign)

Put and ReturnValue

I think it would be very useful to add an argument to get the return value on inserted records with the default behaviour no return.

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.