@aklinker1/zero-factory 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ const user = userFactory({
|
|
|
100
100
|
|
|
101
101
|
#### Function Defaults
|
|
102
102
|
|
|
103
|
-
In addition to static values,
|
|
103
|
+
In addition to static values, the factory definition accepts functions for properties:
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
const userFactory = createFactory({
|
|
@@ -225,7 +225,7 @@ postFactory.with({ user })();
|
|
|
225
225
|
// }
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
Note that `with` returns a factory function, which needs to be called to generate the final object. This allows you to chain other utilities like `.many` or
|
|
228
|
+
Note that `with` returns a factory function, which needs to be called to generate the final object. This allows you to chain other utilities like `.many` and/or traits:
|
|
229
229
|
|
|
230
230
|
```ts
|
|
231
231
|
postFactory.with({ user }).noEmails.many(3);
|
|
@@ -274,28 +274,3 @@ intSequence(); // "prefix-0"
|
|
|
274
274
|
intSequence(); // "prefix-1"
|
|
275
275
|
intSequence(); // "prefix-2"
|
|
276
276
|
```
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
## Future Features?
|
|
281
|
-
|
|
282
|
-
May or may not implement these.
|
|
283
|
-
|
|
284
|
-
- Associations:
|
|
285
|
-
|
|
286
|
-
```ts
|
|
287
|
-
const userIdSequence = createSequence("user-");
|
|
288
|
-
const userFactory = createFactory<User>({
|
|
289
|
-
id: userIdSequence,
|
|
290
|
-
// ...
|
|
291
|
-
});
|
|
292
|
-
const postFactory = createFactory<Post>({
|
|
293
|
-
id: createSequence("post-"),
|
|
294
|
-
userId: userIdSequence,
|
|
295
|
-
}).associate("user", (user: User) => ({
|
|
296
|
-
userId: user.id,
|
|
297
|
-
}));
|
|
298
|
-
|
|
299
|
-
const user = userFactory(); // { id: "user-0", ... }
|
|
300
|
-
postFactory.with({ user })(/* optional overrides */); // { id: "post-0", userId: "user-0", ... }
|
|
301
|
-
```
|