Skip to content

Commit a9dabb2

Browse files
refactor(date.decorator): date -> dateProperty
switch name to avoid naming collision with date
1 parent f35ed6e commit a9dabb2

15 files changed

+36
-42
lines changed

.lintstagedrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
linters:
2-
"{src,test}/**/*.ts":
2+
"{src}/**/*.ts":
33
- prettier --write --config ./.prettierrc.yml
44
- tslint --project ./tsconfig.json -t codeFrame --fix
55
- git add

src/decorator/impl/date/date.decorator.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { metadataForModel, Model, ModelMetadata } from '../..'
33
import { getMetaDataProperty } from '../../../../test/helper'
44
import { updateDynamoEasyConfig } from '../../../config'
55
import { DateToNumberMapper } from '../../../mapper/custom'
6-
import { Date } from './date.decorator'
6+
import { DateProperty } from './date.decorator'
77

88
// important: it's necessary to update dynamo-easy-config BEFORE the models are loaded.
99
updateDynamoEasyConfig({ dateMapper: DateToNumberMapper })
1010

1111
@Model()
1212
class ModelWithDate {
13-
@Date()
13+
@DateProperty()
1414
aDate: Date
1515
}
1616

src/decorator/impl/date/date.decorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { dynamoEasyConfig } from '../../../config/dynamo-easy-config'
22
import { initOrUpdateProperty } from '../property/init-or-update-property.function'
33

4-
export function Date(): PropertyDecorator {
4+
export function DateProperty(): PropertyDecorator {
55
return (target: any, propertyKey: string | symbol) => {
66
if (typeof propertyKey === 'string') {
77
initOrUpdateProperty({ mapper: () => dynamoEasyConfig.dateMapper }, target, propertyKey)

src/decorator/impl/enum/enum.decorator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EnumType } from '../../../mapper/type/enum.type'
22
import { initOrUpdateProperty } from '../property/init-or-update-property.function'
33

4+
// FIXME remove unused
45
export function Enum<T>(enumType?: T): PropertyDecorator {
56
return (target: any, propertyKey: string | symbol) => {
67
if (typeof propertyKey === 'string') {

test/models/complex.model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Date, Model, PartitionKey, Property, SortedSet, SortKey, Transient, TypedSet } from '../../src/dynamo-easy'
1+
import { DateProperty, Model, PartitionKey, Property, SortedSet, SortKey, Transient, TypedSet } from '../../src/dynamo-easy'
22
import { NestedObject } from './nested-object.model'
33

44
@Model({ tableName: 'complex_model' })
@@ -7,10 +7,10 @@ export class ComplexModel {
77
id: string
88

99
@SortKey()
10-
@Date()
10+
@DateProperty()
1111
creationDate: Date
1212

13-
@Date()
13+
@DateProperty()
1414
lastUpdated: Date
1515

1616
@Property({ name: 'isActive' })

test/models/employee.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Date, Model, SortedSet } from '../../src/dynamo-easy'
1+
import { DateProperty, Model, SortedSet } from '../../src/dynamo-easy'
22

33
@Model()
44
export class Employee {
55
name: string
66

77
age: number
88

9-
@Date()
9+
@DateProperty()
1010
createdAt: Date | null
1111

1212
@SortedSet()

test/models/model-with-date-as-key.model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// tslint:disable:max-classes-per-file
2-
import { Date, GSIPartitionKey, Model, PartitionKey, SortKey } from '../../src/dynamo-easy'
2+
import { DateProperty, GSIPartitionKey, Model, PartitionKey, SortKey } from '../../src/dynamo-easy'
33

44
@Model()
55
export class ModelWithDateAsHashKey {
66
@PartitionKey()
7-
@Date()
7+
@DateProperty()
88
startDate: Date
99

1010
constructor(startDate: Date) {
@@ -18,7 +18,7 @@ export class ModelWithDateAsRangeKey {
1818
id: number
1919

2020
@SortKey()
21-
@Date()
21+
@DateProperty()
2222
creationDate: Date
2323

2424
constructor(id: number, creationDate: Date) {
@@ -33,7 +33,7 @@ export class ModelWithDateAsIndexHashKey {
3333
id: number
3434

3535
@GSIPartitionKey('anyGSI')
36-
@Date()
36+
@DateProperty()
3737
creationDate: Date
3838

3939
constructor(id: number, creationDate: Date) {

test/models/model-with-indexes.model.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// tslint:disable:max-classes-per-file
22
import {
3-
Date,
3+
DateProperty,
44
GSIPartitionKey,
55
GSISortKey,
66
LSISortKey,
77
Model,
8-
PartitionKey,
9-
Property,
8+
PartitionKey, Property,
109
SortKey,
1110
} from '../../src/dynamo-easy'
1211

1312
export const INDEX_ACTIVE = 'active-index'
13+
1414
@Model()
1515
export class ModelWithGSI {
1616
@PartitionKey()
1717
id: string
1818

19-
@Date()
19+
@DateProperty()
2020
createdAt: Date
2121

2222
@GSIPartitionKey(INDEX_ACTIVE)
@@ -28,7 +28,7 @@ export class ModelWithLSI {
2828
@PartitionKey()
2929
id: string
3030

31-
@Date()
31+
@DateProperty()
3232
createdAt: Date
3333

3434
@LSISortKey(INDEX_ACTIVE)
@@ -46,7 +46,7 @@ export class ModelWithABunchOfIndexes {
4646

4747
@SortKey()
4848
@GSISortKey(INDEX_ACTIVE_CREATED_AT)
49-
@Date()
49+
@DateProperty()
5050
createdAt: Date
5151

5252
@GSIPartitionKey(INDEX_ACTIVE_CREATED_AT)

test/models/organization.model.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Date,
2+
DateProperty,
33
Model,
44
PartitionKey,
55
Property,
@@ -19,7 +19,7 @@ export class Gift {
1919

2020
@Model()
2121
export class Birthday {
22-
@Date()
22+
@DateProperty()
2323
date: Date
2424

2525
@TypedArray(Gift)
@@ -58,10 +58,10 @@ export class Organization {
5858
name: string
5959

6060
@SortKey()
61-
@Date()
61+
@DateProperty()
6262
createdAtDate: Date
6363

64-
@Date()
64+
@DateProperty()
6565
lastUpdated: Date
6666

6767
// Boolean
@@ -88,7 +88,7 @@ export class Organization {
8888
// simple type, mixed (no metadata required)
8989
randomDetails: any[]
9090

91-
// complex type (requries metadata)
91+
// complex type (requires metadata)
9292
@TypedArray(Employee)
9393
employees: Employee[]
9494

test/models/product.model.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import { NestedComplexModel } from './nested-complex.model'
44

55
@Model()
66
export class ProductNested {
7-
/*
8-
* introduce new decorators
9-
*/
10-
// @SortedArray()
11-
// @Set()
12-
// @Date()
137
@SortedSet()
148
collection: Set<string>
159

@@ -25,11 +19,9 @@ export class ProductNested {
2519

2620
@Model()
2721
export class Product {
28-
// @CustomMapper(ObjectMapper) --> works great
2922
@Property()
3023
nestedValue: NestedComplexModel
3124

32-
// @Type(Array, ProductNested)
3325
@TypedArray(ProductNested)
3426
list: ProductNested[]
3527

0 commit comments

Comments
 (0)