-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmodel-with-collections.model.ts
47 lines (37 loc) · 1.78 KB
/
model-with-collections.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { CollectionProperty, Model } from '../../src/dynamo-easy'
import { NestedModelWithDate } from './nested-model-with-date.model'
import { NestedObject } from './nested-object.model'
import { FormId, formIdMapper } from './real-world'
@Model()
export class ModelWithCollections {
// ================================================================
// should be mapped to (L)ist of (M)aps since itemType is complex
@CollectionProperty({ itemType: NestedModelWithDate })
arrayOfNestedModelToList: NestedModelWithDate[]
@CollectionProperty({ itemType: NestedModelWithDate })
setOfNestedModelToList: Set<NestedModelWithDate>
// ==============================================================================
// should be mapped to (L)ist of (S)trings since it needs to preserve the order
@CollectionProperty({ sorted: true, itemMapper: formIdMapper })
arrayOfFormIdToListWithStrings: FormId[]
@CollectionProperty({ sorted: true, itemMapper: formIdMapper })
setOfFormIdToListWithStrings: Set<FormId>
// ===========================================================================
// should be mapped to (L)ist of (M)aps since it complex type without mapper
@CollectionProperty()
arrayOfObjectsToList: NestedObject[]
@CollectionProperty()
setOfObjectsToList: Set<NestedObject>
// ====================================================================
// should be mapped to (String)(S)et since the itemMapper is provided
@CollectionProperty({ itemMapper: formIdMapper })
arrayOfFormIdToSet: FormId[]
@CollectionProperty({ itemMapper: formIdMapper })
setOfFormIdToSet: Set<FormId>
// should be mapped to List since it is an array
@CollectionProperty()
arrayOfStringToSet: string[]
// should be mapped to Set
@CollectionProperty()
setOfStringToSet: Set<string>
}