Skip to content

Commit

Permalink
Merge pull request #207 from shiftcode/#206-remove-index-limitation
Browse files Browse the repository at this point in the history
fix(model-decorator): remove limitation for index creation
  • Loading branch information
simonmumenthaler authored Apr 24, 2019
2 parents a006e70 + e4c0b19 commit d492ab9
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/decorator/impl/model/model.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getGlobalSecondaryIndexes(properties: Array<PropertyMetadata<any>>): Ma
throw new Error(
`there is already a partition key defined for global secondary index ${indexName} (property name: ${
property.nameDb
})`,
})`,
)
}

Expand All @@ -105,24 +105,15 @@ function getGlobalSecondaryIndexes(properties: Array<PropertyMetadata<any>>): Ma
throw new Error(
`there is already a sort key defined for global secondary index ${indexName} (property name: ${
property.nameDb
})`,
})`,
)
}

gsi.sortKey = property.nameDb
break
}

if (map.has(indexName)) {
map.set(indexName, gsi)
} else {
if (map.size < 5) {
map.set(indexName, gsi)
} else {
// a maximum of 5 global secondary indexes can be defined per table
throw new Error('make sure to define no more than 5 global secondary indexes per model')
}
}
map.set(indexName, gsi)
})

return map
Expand All @@ -148,7 +139,7 @@ function getLocalSecondaryIndexes(
throw new Error(
`only one sort key can be defined for the same local secondary index, ${
property.nameDb
} is already defined as sort key for index ${indexName}`,
} is already defined as sort key for index ${indexName}`,
)
}

Expand Down

0 comments on commit d492ab9

Please sign in to comment.