You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Refactor
* refactor(timestamps): moved existence check to HasTimestamps class
* refactor(events): simplified method signatures
* refactor(model)!: renamed `create` to `make`
* This name hints the behaviour somewhat clearer than before. Previously it might have suggested that some persistence was involved.
* refactor(events): removed redundant union type
* refactor: move fetch mock file
## Chore
* chore: increment version
* chore: eslint changes
* chore(deps-dev): updated ts eslint
## Fix
* fix: allow any values within `handleError`
* Some errors may be handled here and recovered from by returning something. Or perhaps an error is expected and no throwing is necessary.
* fix(events): added missing listener signature to `has` method
* fix(collection): fixed typing issue after typescript update
## Documentation
* docs: doc page linking, grammar and typo fixes
* docs(collection): fixed typo
* docs: add internal inline comments to testing
## Testing
* test: updated jest
## Feature
* feat(collection): improved `pluck` return type
* feat(helpers): add `dataGet` function
## Performance
* perf(collection): shortcut return when 0 given as argument
The `getRawAttributes` method returns all the attributes similarly to [getAttributes](#getattributes) except is does not use the any value transformation.
438
+
The `getRawAttributes` method returns all the attributes similarly to [getAttributes](#getattributes) except is does not use any value transformation.
439
439
440
440
#### getAttributeKeys
441
441
@@ -444,7 +444,7 @@ The `getAttributeKeys` method returns all the attribute keys on the model curren
@@ -546,19 +546,19 @@ The `reset` method will set the attributes to the original values, discarding an
546
546
```js
547
547
importUserfrom'@Models/User';
548
548
549
-
constuser=User.create({ name:'John Doe' });
549
+
constuser=User.make({ name:'John Doe' });
550
550
user.name='new name';
551
551
user.getChanges(); // { name: 'new name' }
552
552
user.reset().getChanges(); // {}
553
553
```
554
554
555
555
#### getOriginal
556
556
557
-
The `getOriginal` method returns the original value in a resolved format. Meaning it will use the [accessor](#mutatorsaccessors) if defined or it will [cast](#casting) the value if cast defined. The method optionally takes a second argument which the method will default to if the key is not found.
557
+
The `getOriginal` method returns the original value in a resolved format. Meaning it will use the [accessor](#mutatorsaccessors) if defined, or it will [cast](#casting) the value if cast defined. The method optionally takes a second argument which the method will default to if the key is not found.
558
558
```js
559
559
importUserfrom'@Models/User';
560
560
561
-
constuser=User.create({ name:'John Doe' });
561
+
constuser=User.make({ name:'John Doe' });
562
562
user.name='Jane Doe';
563
563
user.getOriginal('name'); // 'John Doe'
564
564
user.getOriginal('title', 'Mr.'); // 'Mr.'
@@ -574,7 +574,7 @@ The `getChanges` method returns only the changed data since the model was constr
@@ -631,11 +631,11 @@ The `isDirty` method is an alias of the [hasChanges](#haschanges) method.
631
631
632
632
#### isClean
633
633
634
-
The `isClean` method determines whether the attributes matches with the original attributes since the model constructing. Optionally it can take a key argument in which case it only inspect the given attribute's state.
634
+
The `isClean` method determines whether the attributes match with the original attributes since the model constructing. Optionally it can take a key argument in which case it only inspect the given attribute's state.
Copy file name to clipboardExpand all lines: docs/calliope/model-collection.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Model Collection
2
2
3
-
ModelCollection is a sub class of the [Collection](../helpers/collection.md), therefore all methods are inherited. The following methods have been updated to use either the model's [is](./readme.md#is) method, or the [primary key](./readme.md#getkey) of the model for comparison between models. `unique`, `hasDuplicates`, `duplicates`, `diff`, `only`, `except`, `intersect`, `delete`, `union`, `includes`. The signature of the before mentioned methods has not changed. In addition, the ModelCollection ensures that only [Models](./readme.md) are included in the collection. On top of the collection's methods couple of others has been added that are only relevant to model values.
3
+
ModelCollection is a subclass of the [Collection](../helpers/collection.md), therefore all methods are inherited. The following methods have been updated to use either the model's [is](./readme.md#is) method, or the [primary key](./readme.md#getkey) of the model for comparison between models. `unique`, `hasDuplicates`, `duplicates`, `diff`, `only`, `except`, `intersect`, `delete`, `union`, `includes`. The signature of the before mentioned methods has not changed. In addition, the ModelCollection ensures that only [Models](./readme.md) are included in the collection. On top of the collection's methods couple of others has been added that are only relevant to model values.
Copy file name to clipboardExpand all lines: docs/calliope/readme.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ import User from '@Models/User';
51
51
52
52
User.find(1);
53
53
// or
54
-
User.create({ my: attributes });
54
+
User.make({ my: attributes });
55
55
// etc...
56
56
```
57
57
@@ -97,7 +97,7 @@ export default class User extends Model {
97
97
#### keyType
98
98
99
99
The `keyType` is a getter that identifies what the type is of your [primaryKey](#primarykey). Its value has to be either `'string'` or `'number'` with `'number'` being the default value.
100
-
You should update this value to `'string'` if you're using a uuid or some custom string for the primary key as this is used when in the [Factory](../testing.md#factories) and [exists](#exists) logic.
100
+
You should update this value to `'string'` if you're using a UUID or some custom string for the primary key as this is used when in the [Factory](../testing/readme.md#factories) and [exists](#exists) logic.
101
101
102
102
```js
103
103
// User.ts
@@ -128,9 +128,9 @@ The `is` method compares the given model with the current model based on the [ge
128
128
importUserfrom'@Models/User';
129
129
importShiftfrom'@Models/Shift';
130
130
131
-
constuser=User.create({ id:1 });
132
-
constuser2=User.create({ id:2 });
133
-
constshift=Shift.create({ id:1 });
131
+
constuser=User.make({ id:1 });
132
+
constuser2=User.make({ id:2 });
133
+
constshift=Shift.make({ id:1 });
134
134
135
135
user.is(user); // true
136
136
user.is(user2); // false
@@ -175,7 +175,7 @@ The `create` method instantiates your model while setting up attributes and rela
175
175
```ts
176
176
importUserfrom'@Models/User';
177
177
178
-
const user =User.create({ name: 'User Name' }); // User
178
+
const user =User.make({ name: 'User Name' }); // User
179
179
```
180
180
::: warning
181
181
Constructing a new class like `new User({...})` is **not** acceptable. This will not overwrite your class fields with default values if the same key has been passed in due to how JavaScript first constructs the parent class and only then the subclasses. However, you can still use it to call instance methods. Furthermore, it will not cause unexpected results if using it with the [setAttribute](./attributes.md#setattribute) method or call methods that under the hood uses the [setAttribute](./attributes.md#setattribute).
@@ -187,8 +187,8 @@ When creating an instance and passing in another instance of the model:
187
187
importUserfrom'@Models/User';
188
188
importShiftfrom'@Models/Shift';
189
189
190
-
constuser=User.create({ name:'John Doe' });
191
-
constnewUser=User.create(user);
190
+
constuser=User.make({ name:'John Doe' });
191
+
constnewUser=User.make(user);
192
192
```
193
193
It will clone the [raw attributes](./attributes#getrawattributes) and the [relationships](./relationships.md#getrelations) of the model.
The `factory` is a method that returns a [Factory](../testing.md#factorybuilder) instance. Optionally it takes a number argument which is a shorthand for the [times](../testing.md#times) method.
233
+
The `factory` is a method that returns a [Factory](../testing/readme.md#factorybuilder) instance. Optionally it takes a number argument which is a shorthand for the [times](../testing/readme.md#times)' method.
The `save` method will update or save your model based on whether the model [exists](#exists) or not. If the model exists it will send a `PATCH` request containing the changes, and the optionally passed in attributes. If the model does not exists it will send a `POST` request. The method returns the same current user updated with the response data if any.
256
+
The `save` method will update or save your model based on whether the model [exists](#exists) or not. If the model exists it will send a `PATCH` request containing the changes, and the optionally passed in attributes. If the model does not exist it will send a `POST` request. The method returns the same current user updated with the response data if any.
Copy file name to clipboardExpand all lines: docs/calliope/timestamps.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@ Timestamps are a feature of the model used for tracking changes on your entities
8
8
9
9
#### createdAt
10
10
11
-
The `createdAt` is a static property on the model. The default value is `'createdAt'`. You may over ride this if the expected timestamp attribute is named differently.
11
+
The `createdAt` is a static property on the model. The default value is `'createdAt'`. You may override this if the expected timestamp attribute is named differently.
12
12
The letter casing is no concern here as [getCreatedAtName](#getcreatedatname) will update it to the correct casing.
13
13
14
14
#### updatedAt
15
15
16
-
The `updatedAt` is a static property on the model. The default value is `'updatedAt'`. You may over ride this if the expected timestamp attribute is named differently.
16
+
The `updatedAt` is a static property on the model. The default value is `'updatedAt'`. You may override this if the expected timestamp attribute is named differently.
17
17
The letter casing is no concern here as [getUpdatedAtName](#getupdatedatname) will update it to the correct casing.
The `deletedAt` is a static property on the model. The default value is `'deletedAt'`. You may over ride this if the expected timestamp attribute is named differently.
57
+
The `deletedAt` is a static property on the model. The default value is `'deletedAt'`. You may override this if the expected timestamp attribute is named differently.
58
58
The letter casing is no concern here as [getDeletedAtName](#getdeletedatname) will update it to the correct casing.
When all items in the collections are objects, then you may order them using the `orderBy` method. The method takes one or more objects describing how the collection should be ordered. The object has two properties:
413
413
414
414
-`property` - the name of the property you want to order by OR a method that accepts the collection item and returns the nested value.
415
-
-`direction` - possible values are `asc`, `desc` respective to weather it should be in ascending or descending order.
415
+
-`direction` - possible values are `asc`, `desc` respective to whether it should be in ascending or descending order.
Copy file name to clipboardExpand all lines: docs/helpers/global-config.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,7 @@ This is a `string` that the [model's endpoint](../calliope/api-calls.md#endpoint
145
145
146
146
#### randomDataGenerator
147
147
148
-
This value if set, it will be available for consuming in your [Factories](../testing.md#factories) under the member key [random](../testing.md#random).
148
+
This value if set, it will be available for consuming in your [Factories](../testing/readme.md#factories) under the member key [random](../testing/readme.md#random).
0 commit comments