Giter Club home page Giter Club logo

Comments (5)

arpansoni avatar arpansoni commented on July 3, 2024 1

from dynamoquery.

vemel avatar vemel commented on July 3, 2024

Hello!

THank you for the report, looks like this part of the documentation is outdated.

You can use ProjectionExpression directly.
https://altitudenetworks.github.io/dynamoquery/dynamo_query/expressions.html#projectionexpression

from dynamo_query.expressions import ProjectionExpression

keys = ['first_name', 'last_name']
projection_expression = ProjectionExpression(*keys)

Please let me know if this helps or if you have any further questions.

from dynamoquery.

arpansoni avatar arpansoni commented on July 3, 2024

the solution above did not work as expected. I am using dynamoQuery version 1.0.1 . this is what I have tried thus far.

from  dynamo_query import DynamoQuery
from dynamo_query.expressions  import ConditionExpression, ProjectionExpression
import boto3

table = boto3.resource('dynamodb').Table('mytable')
projection_attributes =["name", "address"]
data={"foo" :"student"}
query = DynamoQuery.build_query(key_condition_expression=(ConditionExpression=("foo")
), projection_expression = (ProjectionExpression(projection_attributes ))
. table(table - table , table_keys=('foo','bar'))

#when i look at the query.__dict__  object the projection expressions look like below 

'ProjectionExpression':<ProjectionExpression "{['name','address']}">},   

#when I pass the hardcoded string to the query 
query = DynamoQuery.build_query(key_condition_expression=(ConditionExpression=("foo")), projection_expression = (ProjectionExpression("name","address")). table(table = table , table_keys=('foo','bar'))

'ProjectionExpression':<ProjectionExpression "{name},{address}">},


the latter works.. the former does not. let me know how can I write the projection expression correctly using version 1.0.1. if you can show me an example using the code above that would be great

Thanks,

from dynamoquery.

vemel avatar vemel commented on July 3, 2024

Sorry, it actually accepts *keys, so it should be ProjectionExpression(*projection_attributes)

from dynamoquery.

arpansoni avatar arpansoni commented on July 3, 2024

yup that worked as expected.

from dynamoquery.

Related Issues (7)

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.