@stacksjs/database 0.40.0 → 0.41.0
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/dist/factory/index.d.ts +4 -3
- package/dist/factory/index.mjs +11 -6
- package/dist/seeder/index.d.ts +1 -1
- package/package.json +3 -2
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Result } from '@stacksjs/types';
|
|
1
2
|
declare class Factory {
|
|
2
3
|
private factory;
|
|
3
4
|
private noOfItems;
|
|
@@ -6,8 +7,8 @@ declare class Factory {
|
|
|
6
7
|
constructor(factory: string);
|
|
7
8
|
define(params: any): this;
|
|
8
9
|
count(count?: number): this;
|
|
9
|
-
make(count?: number): Promise<
|
|
10
|
-
create(count?: number): Promise<
|
|
11
|
-
|
|
10
|
+
make(count?: number): Promise<Result<Object, Error>>;
|
|
11
|
+
create(count?: number): Promise<Result<Object, Error>>;
|
|
12
|
+
initiateColumns(): void;
|
|
12
13
|
}
|
|
13
14
|
export { Factory as factory, Factory };
|
package/dist/factory/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { collect } from "@stacksjs/collections";
|
|
2
|
+
import { loop } from "@stacksjs/utils";
|
|
1
3
|
import { PrismaClient } from "@prisma/client";
|
|
2
|
-
import { ResultAsync } from "@stacksjs/
|
|
4
|
+
import { ResultAsync } from "@stacksjs/error-handling";
|
|
3
5
|
const prisma = new PrismaClient();
|
|
4
6
|
class Factory {
|
|
5
7
|
constructor(factory) {
|
|
@@ -19,7 +21,7 @@ class Factory {
|
|
|
19
21
|
async make(count = 0) {
|
|
20
22
|
if (count)
|
|
21
23
|
this.noOfItems = count;
|
|
22
|
-
this.
|
|
24
|
+
this.initiateColumns();
|
|
23
25
|
return ResultAsync.fromPromise(
|
|
24
26
|
await prisma[this.factory].createMany(
|
|
25
27
|
this.items,
|
|
@@ -31,7 +33,7 @@ class Factory {
|
|
|
31
33
|
async create(count = 0) {
|
|
32
34
|
if (count)
|
|
33
35
|
this.noOfItems = count;
|
|
34
|
-
this.
|
|
36
|
+
this.initiateColumns();
|
|
35
37
|
return ResultAsync.fromPromise(
|
|
36
38
|
await prisma[this.factory].createMany(
|
|
37
39
|
this.items,
|
|
@@ -40,9 +42,12 @@ class Factory {
|
|
|
40
42
|
() => new Error("Failed to create the data")
|
|
41
43
|
);
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
initiateColumns() {
|
|
46
|
+
const items = collect();
|
|
47
|
+
loop(this.noOfItems, () => {
|
|
48
|
+
items.push(this.columns);
|
|
49
|
+
});
|
|
50
|
+
this.items = items;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
export { Factory as factory, Factory };
|
package/dist/seeder/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function seeder(factoryName: any, count?: number): Promise<
|
|
1
|
+
declare function seeder(factoryName: any, count?: number): Promise<Result<Object, Error>>;
|
|
2
2
|
export { seeder };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/database",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.41.0",
|
|
5
5
|
"packageManager": "pnpm@7.16.0",
|
|
6
6
|
"description": "The Stacks database integration.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -43,10 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@prisma/client": "^4.6.1",
|
|
46
|
+
"@stacksjs/utils": "0.41.0",
|
|
46
47
|
"vitest": "^0.25.2"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"mkdist": "^0.
|
|
50
|
+
"mkdist": "^1.0.0",
|
|
50
51
|
"typescript": "^4.8.4"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|