@@ -15,25 +15,29 @@ import { getMetadataType } from '../../util'
1515import { initOrUpdateProperty } from '../property/init-or-update-property.function'
1616import { CollectionPropertyData } from './collection-property-data.model'
1717
18-
19- export function CollectionProperty < R , T extends StringAttribute | NumberAttribute | BinaryAttribute > ( opts : CollectionPropertyData < R , T > = { } ) : PropertyDecorator {
18+ export function CollectionProperty < R , T extends StringAttribute | NumberAttribute | BinaryAttribute > (
19+ opts : CollectionPropertyData < R , T > = { } ,
20+ ) : PropertyDecorator {
2021 return ( target : object , propertyKey : string | symbol ) => {
2122 if ( typeof propertyKey === 'string' ) {
22-
2323 const type : ModelConstructor < any > = getMetadataType ( target , propertyKey )
2424
25- if ( type === undefined ) {
26- throw new Error ( 'make sure you have enabled the typescript compiler options which enable us to work with decorators (see doc)' )
25+ if ( type === undefined ) {
26+ throw new Error (
27+ 'make sure you have enabled the typescript compiler options which enable us to work with decorators (see doc)' ,
28+ )
2729 }
2830
2931 if ( type !== Set && type !== Array ) {
30- throw new Error ( `[${ target . constructor . name } ::${ propertyKey } ] The CollectionProperty decorator is meant for properties of type Set or Array` )
32+ throw new Error (
33+ `[${ target . constructor . name } ::${ propertyKey } ] The CollectionProperty decorator is meant for properties of type Set or Array` ,
34+ )
3135 }
3236
3337 const meta : Partial < PropertyMetadata < any > > & { typeInfo : TypeInfo } = {
3438 name : propertyKey ,
35- nameDb : opts && opts . name || propertyKey ,
36- typeInfo : { type} ,
39+ nameDb : ( opts && opts . name ) || propertyKey ,
40+ typeInfo : { type } ,
3741 isSortedCollection : ! ! opts . sorted ,
3842 }
3943
@@ -51,11 +55,12 @@ export function CollectionProperty<R, T extends StringAttribute | NumberAttribut
5155 if ( hasItemMapper ) {
5256 const itemMapper = < MapperForType < any , any > > opts . itemMapper
5357
54- const wrappedMapper : MapperForType < any , any > = type === Array
55- ? ! ! opts . sorted
56- ? wrapMapperForDynamoListJsArray ( itemMapper )
57- : wrapMapperForDynamoSetJsArray ( itemMapper )
58- : ! ! opts . sorted
58+ const wrappedMapper : MapperForType < any , any > =
59+ type === Array
60+ ? ! ! opts . sorted
61+ ? wrapMapperForDynamoListJsArray ( itemMapper )
62+ : wrapMapperForDynamoSetJsArray ( itemMapper )
63+ : ! ! opts . sorted
5964 ? wrapMapperForDynamoListJsSet ( itemMapper )
6065 : wrapMapperForDynamoSetJsSet ( itemMapper )
6166
0 commit comments