Giter VIP home page Giter VIP logo

Comments (5)

sreimer15 avatar sreimer15 commented on June 17, 2024 1

So I've been playing around with nosql-workbench from aws and they have a concept of a "facet".

Which is the "The access patterns of the application that will interact with the table."
In that GUI
You can define a name for your facet
an alias for the partion key
and an alias for your sort key
as well as "other attributes" to include

So perhaps in your domain object you can define a "facet" with its own primary and secondary key compositions as well as aliases. That way you're encouraging the end user to think about their access patterns before hand.

Screen Shot 2020-01-02 at 8 56 53 PM

const item = { 
   globalSortKeyAlias,
   primaryKeyAlias
}

User.query("facetName", item)

Perhaps other attribute projection is not part of the MVP

What do you think? I really like what you've done and I appreciate the care you've put in to encourage best practices and single table design with dynamo db. Thank you!

from dynamodb-toolbox.

tomaswisten avatar tomaswisten commented on June 17, 2024

Yes, querying seems to be the missing piece for my use cases as well. Thanks for a promising project!

from dynamodb-toolbox.

jeremydaly avatar jeremydaly commented on June 17, 2024

Thanks for the feedback and kind words @sreimer15! The access pattern/facet thing was something I was thinking about in issue #8, but that's an interesting thought to tie the two together.

I think there still needs to be a low-level querying capability, but definitely something to think of.

from dynamodb-toolbox.

DaKaZ avatar DaKaZ commented on June 17, 2024

@jeremydaly what do you think about this syntax for building the query params:

Model.query({
  pk: 'hashKey', // you would use your Model's pk definition or alias here
  index: 'gsiName', // optional, only if using a GSI with query
  limit: 10, // optional limit
  sortKey: {  // optional, if omitted the query would just be on the partition key
    operator: '=', // =, >, >=, <, <=, between, begins_with
    value: '',
    secondaryValue: '', // only used with between
    consistentRead: true, // optional, default false
  },
  filter: { // filter is optional
    key: 'keyName',
    operator: '=', // =, >, >=, <, <=, between, begins_with
    value: '',
    secondaryValue: '' // only used with between
  }
})

It seems like we could build all the syntax needed with that and it would similar syntax/methods as the get/put functionality in the library already. So a minimal example would look like:

const queryParams = MyModel.query({ pk: '123abc' })

And a more complete example:

const queryParams = MyModel.query({ 
  pk: '123abc',
  limit: 10,
  sortKey: {
    operator: 'begins_with'
    value: 'meta' // the first part of a compounded key
  }
})

from dynamodb-toolbox.

jeremydaly avatar jeremydaly commented on June 17, 2024

Added in the v0.2 branch.

from dynamodb-toolbox.

Related Issues (20)

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.