[FEATURE] v3 single table attribute mapping
See original GitHub issueSummary:
I’m using the alpha of v3 to build out a single table design using multiple models each with their own schema. As a result of this single table design I’m using generic attributes (pk
, sk
, etc.) to store different things depending on the model. The problem is that you lose the meaning of these values on the different models.
Is there any plan to introduce a mapping of model attributes to underlying table attributes?
Example
const userSchema = new dynamoose.Schema({
"id": {
type: String,
map: "pk"
}
"type": {
type: String,
map: "sk"
}
});
const orderSchema = new dynamoose.Schema({
"userId": {
type: String,
map: "pk"
}
"orderId": {
type: String,
map: "sk"
}
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Attribute field mapping—ArcGIS Pro | Documentation
Use the Field Map parameter to control how attribute fields from the input datasets are processed and written, or mapped, to the output...
Read more >QGIS: create layout with one map its attribute table per feature
I have 800 features in the survey. The goal is to create 800 individual PDFs that have a map and attribute table of...
Read more >Viewing and Editing the Attribute Table in ArcGIS Pro - YouTube
In the video we edit some attributes both as single records, then also as multiple records using the 'calculate field' function.
Read more >Attribute Table - MapStore
In GIS, the Attribute Table associated to a vector layer is a table that stores tabular information related to the layer. The columns...
Read more >SchemaMapper: Attribute Mapping - FME Community
Attribute mapping is the act of transforming and/or connecting one or more ... commas in your lookup table CSV can confuse FME during...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@alexedwardjones Nope, no plans until you created this issue 😉. Love this idea tho. I will prioritize it for v3. Really appreciate the feedback and feature suggestion.
Also, thank you for trying v3. Any feedback (good or bad) is appreciated. Even good feedback tells us that we are almost ready to ship. So really appreciate it. Feel free to continue to create issues or contact me with any other feedback.
Thanks again!
@AlisonVilela
How would this work? Would it just
prefix
all values with a certain prefix string? How would this work on reads from DynamoDB? Or would it only apply to saves? How about a prefix on a key property and you get using that property? Would the value you get on be prefixed with that value before running the query?Something similar that you might want to look into is the
set
function: https://beta.dynamoosejs.com/guide/Schema#set-function--async-function. This would allow you to set a function that gets run whenever saving an item to DynamoDB, and also when retrieving an item with that property as part of the query. I think that might meet your needs here.I don’t understand what you mean here. In DynamoDB you can only have one primary key, and one sort key. You can’t have multiple of both. Just not allowed in DynamoDB.
If you are wanting to combine two attributes that you have into a single
PK
orSK
attribute, that can be easily achieved using thecombine
type in Dynamoose: https://beta.dynamoosejs.com/guide/Schema#attribute-types. However, it is important to note that the underlying values will also be stored as part of your item.For example, lets say you had a
raceId
property, and apartId
property. And you want yourPK
to be the values of both of those properties, separated by a-
. You could use the Combine type on yourPK
property, and have it combine the raceId and partId values automatically for you. But the underlying item will still include the raceId and partId values as different attributes.Apologies, but I don’t understand what you mean here at all.
Hopefully this answers your questions.