Skip to content

Commit e4c0b19

Browse files
fix(model-decorator): remove limitation for index creation
it is not our job to make assumptions about such limitations, removing the check. Also the check was not correct. By default 5 LSI and 20 GSI are allowed.(https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-secondary-indexes)
1 parent a006e70 commit e4c0b19

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/decorator/impl/model/model.decorator.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function getGlobalSecondaryIndexes(properties: Array<PropertyMetadata<any>>): Ma
9494
throw new Error(
9595
`there is already a partition key defined for global secondary index ${indexName} (property name: ${
9696
property.nameDb
97-
})`,
97+
})`,
9898
)
9999
}
100100

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

112112
gsi.sortKey = property.nameDb
113113
break
114114
}
115115

116-
if (map.has(indexName)) {
117-
map.set(indexName, gsi)
118-
} else {
119-
if (map.size < 5) {
120-
map.set(indexName, gsi)
121-
} else {
122-
// a maximum of 5 global secondary indexes can be defined per table
123-
throw new Error('make sure to define no more than 5 global secondary indexes per model')
124-
}
125-
}
116+
map.set(indexName, gsi)
126117
})
127118

128119
return map
@@ -148,7 +139,7 @@ function getLocalSecondaryIndexes(
148139
throw new Error(
149140
`only one sort key can be defined for the same local secondary index, ${
150141
property.nameDb
151-
} is already defined as sort key for index ${indexName}`,
142+
} is already defined as sort key for index ${indexName}`,
152143
)
153144
}
154145

0 commit comments

Comments
 (0)