@reldens/storage 0.88.0 → 0.89.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/.claude/driver-methods-complete-analysis.md +1978 -0
- package/.claude/test-architecture.md +973 -0
- package/CLAUDE.md +121 -1
- package/bin/reldens-storage.js +1 -1
- package/lib/base-driver.js +8 -0
- package/lib/entities-generator.js +1 -3
- package/lib/entity-templates/mikro-orm-model.template +2 -1
- package/lib/generators/models-generation.js +126 -5
- package/lib/mikro-orm/mikro-orm-data-server.js +24 -10
- package/lib/mikro-orm/mikro-orm-driver.js +184 -116
- package/lib/objection-js/objection-js-driver.js +111 -19
- package/lib/prisma/prisma-data-server.js +3 -2
- package/lib/prisma/prisma-driver.js +12 -10
- package/lib/prisma/prisma-filter-processor.js +193 -146
- package/lib/prisma/prisma-metadata-loader.js +0 -4
- package/lib/prisma/prisma-relation-resolver.js +292 -267
- package/lib/prisma/prisma-type-caster.js +280 -260
- package/package.json +15 -6
- package/tests/.env.test.example +7 -0
- package/tests/fixtures/categories-fixtures.js +164 -0
- package/tests/fixtures/expected-entities-mikro-orm/entities/test-categories-entity.js +70 -0
- package/tests/fixtures/expected-entities-mikro-orm/entities/test-products-entity.js +95 -0
- package/tests/fixtures/expected-entities-mikro-orm/entities/test-reviews-entity.js +84 -0
- package/tests/fixtures/expected-entities-mikro-orm/entities-config.js +17 -0
- package/tests/fixtures/expected-entities-mikro-orm/entities-translations.js +13 -0
- package/tests/fixtures/expected-entities-mikro-orm/models/mikro-orm/registered-models-mikro-orm.js +23 -0
- package/tests/fixtures/expected-entities-mikro-orm/models/mikro-orm/test-categories-model.js +57 -0
- package/tests/fixtures/expected-entities-mikro-orm/models/mikro-orm/test-products-model.js +79 -0
- package/tests/fixtures/expected-entities-mikro-orm/models/mikro-orm/test-reviews-model.js +70 -0
- package/tests/fixtures/expected-entities-objection-js/entities/test-categories-entity.js +70 -0
- package/tests/fixtures/expected-entities-objection-js/entities/test-products-entity.js +95 -0
- package/tests/fixtures/expected-entities-objection-js/entities/test-reviews-entity.js +84 -0
- package/tests/fixtures/expected-entities-objection-js/entities-config.js +17 -0
- package/tests/fixtures/expected-entities-objection-js/entities-translations.js +13 -0
- package/tests/fixtures/expected-entities-objection-js/models/objection-js/registered-models-objection-js.js +23 -0
- package/tests/fixtures/expected-entities-objection-js/models/objection-js/test-categories-model.js +33 -0
- package/tests/fixtures/expected-entities-objection-js/models/objection-js/test-products-model.js +42 -0
- package/tests/fixtures/expected-entities-objection-js/models/objection-js/test-reviews-model.js +33 -0
- package/tests/fixtures/expected-entities-prisma/entities/test-categories-entity.js +70 -0
- package/tests/fixtures/expected-entities-prisma/entities/test-products-entity.js +95 -0
- package/tests/fixtures/expected-entities-prisma/entities/test-reviews-entity.js +84 -0
- package/tests/fixtures/expected-entities-prisma/entities-config.js +17 -0
- package/tests/fixtures/expected-entities-prisma/entities-translations.js +13 -0
- package/tests/fixtures/expected-entities-prisma/models/prisma/registered-models-prisma.js +23 -0
- package/tests/fixtures/expected-entities-prisma/models/prisma/test-categories-model.js +43 -0
- package/tests/fixtures/expected-entities-prisma/models/prisma/test-products-model.js +50 -0
- package/tests/fixtures/expected-entities-prisma/models/prisma/test-reviews-model.js +46 -0
- package/tests/fixtures/products-fixtures.js +119 -0
- package/tests/fixtures/reviews-fixtures.js +42 -0
- package/tests/fixtures/sql/test-schema.sql +59 -0
- package/tests/integration/test-drivers.js +257 -0
- package/tests/integration/test-nested-filters.js +408 -0
- package/tests/integration/test-relations.js +349 -0
- package/tests/run-tests.js +213 -0
- package/tests/unit/test-drivers.js +89 -0
- package/tests/unit/test-entities-generator.js +533 -0
- package/tests/unit/test-entity-manager.js +128 -0
- package/tests/unit/test-type-mapper.js +232 -0
- package/tests/utils/custom-reporter.js +73 -0
- package/tests/utils/driver-registry.js +144 -0
- package/tests/utils/prisma-subprocess-worker.js +150 -0
- package/tests/utils/test-helpers.js +726 -0
- package/tests/utils/test-runner.js +63 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - Test Categories Fixtures
|
|
4
|
+
* Universal fixtures for all drivers (no driver-specific nesting)
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports.CategoriesFixtures = {
|
|
9
|
+
category_create_single: {
|
|
10
|
+
name: 'Electronics',
|
|
11
|
+
description: 'Electronic devices and gadgets',
|
|
12
|
+
is_active: 1,
|
|
13
|
+
display_order: 1,
|
|
14
|
+
slug: 'electronics'
|
|
15
|
+
},
|
|
16
|
+
category_create_json: {
|
|
17
|
+
name: 'Books',
|
|
18
|
+
description: 'Books and literature',
|
|
19
|
+
is_active: 1,
|
|
20
|
+
display_order: 2,
|
|
21
|
+
slug: 'books'
|
|
22
|
+
},
|
|
23
|
+
category_create_enum: {
|
|
24
|
+
name: 'Clothing',
|
|
25
|
+
description: 'Apparel and fashion',
|
|
26
|
+
is_active: 0,
|
|
27
|
+
display_order: 3,
|
|
28
|
+
slug: 'clothing'
|
|
29
|
+
},
|
|
30
|
+
category_unique_test: {
|
|
31
|
+
name: 'Sports',
|
|
32
|
+
description: 'Sports equipment and gear',
|
|
33
|
+
is_active: 1,
|
|
34
|
+
display_order: 4,
|
|
35
|
+
slug: 'sports'
|
|
36
|
+
},
|
|
37
|
+
category_update_by_id: {
|
|
38
|
+
id: 1100,
|
|
39
|
+
name: 'Furniture',
|
|
40
|
+
description: 'Home and office furniture',
|
|
41
|
+
is_active: 1,
|
|
42
|
+
display_order: 1,
|
|
43
|
+
slug: 'furniture'
|
|
44
|
+
},
|
|
45
|
+
category_update_by_filters: {
|
|
46
|
+
id: 1101,
|
|
47
|
+
name: 'Toys',
|
|
48
|
+
description: 'Toys and games',
|
|
49
|
+
is_active: 1,
|
|
50
|
+
display_order: 2,
|
|
51
|
+
slug: 'toys'
|
|
52
|
+
},
|
|
53
|
+
category_update_by_field: {
|
|
54
|
+
id: 1102,
|
|
55
|
+
name: 'Garden',
|
|
56
|
+
description: 'Garden tools and supplies',
|
|
57
|
+
is_active: 1,
|
|
58
|
+
display_order: 3,
|
|
59
|
+
slug: 'garden'
|
|
60
|
+
},
|
|
61
|
+
category_upsert_new: {
|
|
62
|
+
id: 1103,
|
|
63
|
+
name: 'Automotive',
|
|
64
|
+
description: 'Auto parts and accessories',
|
|
65
|
+
is_active: 1,
|
|
66
|
+
display_order: 4,
|
|
67
|
+
slug: 'automotive'
|
|
68
|
+
},
|
|
69
|
+
category_delete_by_id: {
|
|
70
|
+
id: 1200,
|
|
71
|
+
name: 'Music',
|
|
72
|
+
description: 'Musical instruments and equipment',
|
|
73
|
+
is_active: 1,
|
|
74
|
+
display_order: 1,
|
|
75
|
+
slug: 'music'
|
|
76
|
+
},
|
|
77
|
+
category_delete_by_filters: {
|
|
78
|
+
id: 1201,
|
|
79
|
+
name: 'Art',
|
|
80
|
+
description: 'Art supplies and materials',
|
|
81
|
+
is_active: 1,
|
|
82
|
+
display_order: 2,
|
|
83
|
+
slug: 'art'
|
|
84
|
+
},
|
|
85
|
+
category_query_1: {
|
|
86
|
+
id: 1300,
|
|
87
|
+
name: 'Query Test 1',
|
|
88
|
+
description: 'First category for query tests',
|
|
89
|
+
is_active: 1,
|
|
90
|
+
display_order: 1,
|
|
91
|
+
slug: 'query-test-1'
|
|
92
|
+
},
|
|
93
|
+
category_query_2: {
|
|
94
|
+
id: 1301,
|
|
95
|
+
name: 'Query Test 2',
|
|
96
|
+
description: 'Second category for query tests',
|
|
97
|
+
is_active: 1,
|
|
98
|
+
display_order: 2,
|
|
99
|
+
slug: 'query-test-2'
|
|
100
|
+
},
|
|
101
|
+
category_query_3: {
|
|
102
|
+
id: 1302,
|
|
103
|
+
name: 'Query Test 3',
|
|
104
|
+
description: 'Third category for query tests',
|
|
105
|
+
is_active: 0,
|
|
106
|
+
display_order: 3,
|
|
107
|
+
slug: 'query-test-3'
|
|
108
|
+
},
|
|
109
|
+
category_reviews_crud: {
|
|
110
|
+
id: 1400,
|
|
111
|
+
name: 'Reviews CRUD Test',
|
|
112
|
+
description: 'Category for reviews CRUD tests',
|
|
113
|
+
is_active: 1,
|
|
114
|
+
display_order: 1,
|
|
115
|
+
slug: 'reviews-crud-test'
|
|
116
|
+
},
|
|
117
|
+
category_filters_1: {
|
|
118
|
+
id: 1500,
|
|
119
|
+
name: 'Filters Test 1',
|
|
120
|
+
description: 'First category for filter tests',
|
|
121
|
+
is_active: 1,
|
|
122
|
+
display_order: 1,
|
|
123
|
+
slug: 'filters-test-1'
|
|
124
|
+
},
|
|
125
|
+
category_filters_2: {
|
|
126
|
+
id: 1501,
|
|
127
|
+
name: 'Filters Test 2',
|
|
128
|
+
description: 'Second category for filter tests',
|
|
129
|
+
is_active: 1,
|
|
130
|
+
display_order: 2,
|
|
131
|
+
slug: 'filters-test-2'
|
|
132
|
+
},
|
|
133
|
+
category_filters_3: {
|
|
134
|
+
id: 1502,
|
|
135
|
+
name: 'Filters Test 3',
|
|
136
|
+
description: 'Third category for filter tests',
|
|
137
|
+
is_active: 0,
|
|
138
|
+
display_order: 3,
|
|
139
|
+
slug: 'filters-test-3'
|
|
140
|
+
},
|
|
141
|
+
category_relations_1: {
|
|
142
|
+
id: 1600,
|
|
143
|
+
name: 'Relations Test 1',
|
|
144
|
+
description: 'First category for relations tests',
|
|
145
|
+
is_active: 1,
|
|
146
|
+
display_order: 1,
|
|
147
|
+
slug: 'relations-test-1'
|
|
148
|
+
},
|
|
149
|
+
category_relations_2: {
|
|
150
|
+
id: 1601,
|
|
151
|
+
name: 'Relations Test 2',
|
|
152
|
+
description: 'Second category for relations tests',
|
|
153
|
+
is_active: 1,
|
|
154
|
+
display_order: 2,
|
|
155
|
+
slug: 'relations-test-2'
|
|
156
|
+
},
|
|
157
|
+
category_create_nested: {
|
|
158
|
+
name: 'Nested Create Category',
|
|
159
|
+
description: 'Category for createWithRelations test',
|
|
160
|
+
is_active: 1,
|
|
161
|
+
display_order: 10,
|
|
162
|
+
slug: 'nested-create-category'
|
|
163
|
+
}
|
|
164
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - TestCategoriesEntity
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { EntityProperties } = require('../../index');
|
|
8
|
+
const { sc } = require('@reldens/utils');
|
|
9
|
+
|
|
10
|
+
class TestCategoriesEntity extends EntityProperties
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
static propertiesConfig(extraProps)
|
|
14
|
+
{
|
|
15
|
+
let titleProperty = 'name';
|
|
16
|
+
let properties = {
|
|
17
|
+
id: {
|
|
18
|
+
isId: true,
|
|
19
|
+
type: 'number',
|
|
20
|
+
isRequired: true,
|
|
21
|
+
dbType: 'int'
|
|
22
|
+
},
|
|
23
|
+
[titleProperty]: {
|
|
24
|
+
isRequired: true,
|
|
25
|
+
dbType: 'varchar'
|
|
26
|
+
},
|
|
27
|
+
slug: {
|
|
28
|
+
isRequired: true,
|
|
29
|
+
dbType: 'varchar'
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
type: 'textarea',
|
|
33
|
+
dbType: 'text'
|
|
34
|
+
},
|
|
35
|
+
is_active: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
dbType: 'tinyint'
|
|
38
|
+
},
|
|
39
|
+
display_order: {
|
|
40
|
+
type: 'number',
|
|
41
|
+
dbType: 'int'
|
|
42
|
+
},
|
|
43
|
+
created_at: {
|
|
44
|
+
type: 'datetime',
|
|
45
|
+
dbType: 'timestamp'
|
|
46
|
+
},
|
|
47
|
+
updated_at: {
|
|
48
|
+
type: 'datetime',
|
|
49
|
+
dbType: 'timestamp'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
let propertiesKeys = Object.keys(properties);
|
|
53
|
+
let showProperties = propertiesKeys;
|
|
54
|
+
let editProperties = sc.removeFromArray([...propertiesKeys], ['id', 'created_at', 'updated_at']);
|
|
55
|
+
let listProperties = [...propertiesKeys];
|
|
56
|
+
listProperties.splice(listProperties.indexOf('description'), 1);
|
|
57
|
+
return {
|
|
58
|
+
showProperties,
|
|
59
|
+
editProperties,
|
|
60
|
+
listProperties,
|
|
61
|
+
filterProperties: listProperties,
|
|
62
|
+
properties,
|
|
63
|
+
titleProperty,
|
|
64
|
+
...extraProps
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports.TestCategoriesEntity = TestCategoriesEntity;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - TestProductsEntity
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { EntityProperties } = require('../../index');
|
|
8
|
+
const { sc } = require('@reldens/utils');
|
|
9
|
+
|
|
10
|
+
class TestProductsEntity extends EntityProperties
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
static propertiesConfig(extraProps)
|
|
14
|
+
{
|
|
15
|
+
let titleProperty = 'name';
|
|
16
|
+
let properties = {
|
|
17
|
+
id: {
|
|
18
|
+
isId: true,
|
|
19
|
+
type: 'number',
|
|
20
|
+
isRequired: true,
|
|
21
|
+
dbType: 'int'
|
|
22
|
+
},
|
|
23
|
+
category_id: {
|
|
24
|
+
type: 'reference',
|
|
25
|
+
reference: 'test_categories',
|
|
26
|
+
isRequired: true,
|
|
27
|
+
dbType: 'int'
|
|
28
|
+
},
|
|
29
|
+
[titleProperty]: {
|
|
30
|
+
isRequired: true,
|
|
31
|
+
dbType: 'varchar'
|
|
32
|
+
},
|
|
33
|
+
sku: {
|
|
34
|
+
isRequired: true,
|
|
35
|
+
dbType: 'varchar'
|
|
36
|
+
},
|
|
37
|
+
description: {
|
|
38
|
+
type: 'textarea',
|
|
39
|
+
dbType: 'text'
|
|
40
|
+
},
|
|
41
|
+
price: {
|
|
42
|
+
type: 'number',
|
|
43
|
+
isRequired: true,
|
|
44
|
+
dbType: 'decimal'
|
|
45
|
+
},
|
|
46
|
+
stock_quantity: {
|
|
47
|
+
type: 'number',
|
|
48
|
+
dbType: 'int'
|
|
49
|
+
},
|
|
50
|
+
is_featured: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
dbType: 'tinyint'
|
|
53
|
+
},
|
|
54
|
+
metadata: {
|
|
55
|
+
type: 'textarea',
|
|
56
|
+
dbType: 'json'
|
|
57
|
+
},
|
|
58
|
+
tags: {
|
|
59
|
+
dbType: 'varchar'
|
|
60
|
+
},
|
|
61
|
+
status: {
|
|
62
|
+
availableValues: [
|
|
63
|
+
{value: 1, label: 'draft'},
|
|
64
|
+
{value: 2, label: 'published'},
|
|
65
|
+
{value: 3, label: 'archived'}
|
|
66
|
+
],
|
|
67
|
+
dbType: 'enum'
|
|
68
|
+
},
|
|
69
|
+
created_at: {
|
|
70
|
+
type: 'datetime',
|
|
71
|
+
dbType: 'timestamp'
|
|
72
|
+
},
|
|
73
|
+
updated_at: {
|
|
74
|
+
type: 'datetime',
|
|
75
|
+
dbType: 'timestamp'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
let propertiesKeys = Object.keys(properties);
|
|
79
|
+
let showProperties = propertiesKeys;
|
|
80
|
+
let editProperties = sc.removeFromArray([...propertiesKeys], ['id', 'created_at', 'updated_at']);
|
|
81
|
+
let listProperties = sc.removeFromArray([...propertiesKeys], ['description', 'metadata']);
|
|
82
|
+
return {
|
|
83
|
+
showProperties,
|
|
84
|
+
editProperties,
|
|
85
|
+
listProperties,
|
|
86
|
+
filterProperties: listProperties,
|
|
87
|
+
properties,
|
|
88
|
+
titleProperty,
|
|
89
|
+
...extraProps
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports.TestProductsEntity = TestProductsEntity;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - TestReviewsEntity
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { EntityProperties } = require('../../index');
|
|
8
|
+
const { sc } = require('@reldens/utils');
|
|
9
|
+
|
|
10
|
+
class TestReviewsEntity extends EntityProperties
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
static propertiesConfig(extraProps)
|
|
14
|
+
{
|
|
15
|
+
let titleProperty = 'title';
|
|
16
|
+
let properties = {
|
|
17
|
+
id: {
|
|
18
|
+
isId: true,
|
|
19
|
+
type: 'number',
|
|
20
|
+
isRequired: true,
|
|
21
|
+
dbType: 'int'
|
|
22
|
+
},
|
|
23
|
+
product_id: {
|
|
24
|
+
type: 'reference',
|
|
25
|
+
reference: 'test_products',
|
|
26
|
+
isRequired: true,
|
|
27
|
+
dbType: 'int'
|
|
28
|
+
},
|
|
29
|
+
reviewer_name: {
|
|
30
|
+
isRequired: true,
|
|
31
|
+
dbType: 'varchar'
|
|
32
|
+
},
|
|
33
|
+
reviewer_email: {
|
|
34
|
+
isRequired: true,
|
|
35
|
+
dbType: 'varchar'
|
|
36
|
+
},
|
|
37
|
+
rating: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
isRequired: true,
|
|
40
|
+
dbType: 'tinyint'
|
|
41
|
+
},
|
|
42
|
+
[titleProperty]: {
|
|
43
|
+
dbType: 'varchar'
|
|
44
|
+
},
|
|
45
|
+
comment: {
|
|
46
|
+
type: 'textarea',
|
|
47
|
+
dbType: 'text'
|
|
48
|
+
},
|
|
49
|
+
is_verified: {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
dbType: 'tinyint'
|
|
52
|
+
},
|
|
53
|
+
helpful_count: {
|
|
54
|
+
type: 'number',
|
|
55
|
+
dbType: 'int'
|
|
56
|
+
},
|
|
57
|
+
created_at: {
|
|
58
|
+
type: 'datetime',
|
|
59
|
+
dbType: 'timestamp'
|
|
60
|
+
},
|
|
61
|
+
updated_at: {
|
|
62
|
+
type: 'datetime',
|
|
63
|
+
dbType: 'timestamp'
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
let propertiesKeys = Object.keys(properties);
|
|
67
|
+
let showProperties = propertiesKeys;
|
|
68
|
+
let editProperties = sc.removeFromArray([...propertiesKeys], ['id', 'created_at', 'updated_at']);
|
|
69
|
+
let listProperties = [...propertiesKeys];
|
|
70
|
+
listProperties.splice(listProperties.indexOf('comment'), 1);
|
|
71
|
+
return {
|
|
72
|
+
showProperties,
|
|
73
|
+
editProperties,
|
|
74
|
+
listProperties,
|
|
75
|
+
filterProperties: listProperties,
|
|
76
|
+
properties,
|
|
77
|
+
titleProperty,
|
|
78
|
+
...extraProps
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports.TestReviewsEntity = TestReviewsEntity;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - Entities Config
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { TestCategoriesEntity } = require('./entities/test-categories-entity');
|
|
8
|
+
const { TestProductsEntity } = require('./entities/test-products-entity');
|
|
9
|
+
const { TestReviewsEntity } = require('./entities/test-reviews-entity');
|
|
10
|
+
|
|
11
|
+
let entitiesConfig = {
|
|
12
|
+
testCategories: TestCategoriesEntity.propertiesConfig(),
|
|
13
|
+
testProducts: TestProductsEntity.propertiesConfig(),
|
|
14
|
+
testReviews: TestReviewsEntity.propertiesConfig()
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports.entitiesConfig = entitiesConfig;
|
package/tests/fixtures/expected-entities-mikro-orm/models/mikro-orm/registered-models-mikro-orm.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - Registered Models
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const testCategoriesModel = require('./test-categories-model');
|
|
8
|
+
const testProductsModel = require('./test-products-model');
|
|
9
|
+
const testReviewsModel = require('./test-reviews-model');
|
|
10
|
+
const { entitiesConfig } = require('../../entities-config');
|
|
11
|
+
const { entitiesTranslations } = require('../../entities-translations');
|
|
12
|
+
|
|
13
|
+
let rawRegisteredEntities = {
|
|
14
|
+
testCategories: testCategoriesModel,
|
|
15
|
+
testProducts: testProductsModel,
|
|
16
|
+
testReviews: testReviewsModel
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports.rawRegisteredEntities = rawRegisteredEntities;
|
|
20
|
+
|
|
21
|
+
module.exports.entitiesConfig = entitiesConfig;
|
|
22
|
+
|
|
23
|
+
module.exports.entitiesTranslations = entitiesTranslations;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - TestCategoriesModel
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { MikroOrmCore } = require('../../../index');
|
|
8
|
+
const { EntitySchema } = MikroOrmCore;
|
|
9
|
+
|
|
10
|
+
class TestCategoriesModel
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
constructor(id, name, slug, description, is_active, display_order, created_at, updated_at)
|
|
14
|
+
{
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.slug = slug;
|
|
18
|
+
this.description = description;
|
|
19
|
+
this.is_active = is_active;
|
|
20
|
+
this.display_order = display_order;
|
|
21
|
+
this.created_at = created_at;
|
|
22
|
+
this.updated_at = updated_at;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static createByProps(props)
|
|
26
|
+
{
|
|
27
|
+
const {id, name, slug, description, is_active, display_order, created_at, updated_at} = props;
|
|
28
|
+
return new this(id, name, slug, description, is_active, display_order, created_at, updated_at);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const schema = new EntitySchema({
|
|
34
|
+
class: TestCategoriesModel,
|
|
35
|
+
tableName: 'test_categories',
|
|
36
|
+
properties: {
|
|
37
|
+
id: { type: 'number', primary: true },
|
|
38
|
+
name: { type: 'string' },
|
|
39
|
+
slug: { type: 'string' },
|
|
40
|
+
description: { type: 'string', nullable: true },
|
|
41
|
+
is_active: { type: 'number', nullable: true },
|
|
42
|
+
display_order: { type: 'number', nullable: true },
|
|
43
|
+
created_at: { type: 'Date', nullable: true },
|
|
44
|
+
updated_at: { type: 'Date', nullable: true },
|
|
45
|
+
related_test_products: {
|
|
46
|
+
kind: '1:m',
|
|
47
|
+
entity: 'TestProductsModel',
|
|
48
|
+
mappedBy: 'related_test_categories'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
TestCategoriesModel,
|
|
55
|
+
entity: TestCategoriesModel,
|
|
56
|
+
schema: schema
|
|
57
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - TestProductsModel
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { MikroOrmCore } = require('../../../index');
|
|
8
|
+
const { EntitySchema } = MikroOrmCore;
|
|
9
|
+
|
|
10
|
+
class TestProductsModel
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
constructor(id, category_id, name, sku, description, price, stock_quantity, is_featured, metadata, tags, status, created_at, updated_at)
|
|
14
|
+
{
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.category_id = category_id;
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.sku = sku;
|
|
19
|
+
this.description = description;
|
|
20
|
+
this.price = price;
|
|
21
|
+
this.stock_quantity = stock_quantity;
|
|
22
|
+
this.is_featured = is_featured;
|
|
23
|
+
this.metadata = metadata;
|
|
24
|
+
this.tags = tags;
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.created_at = created_at;
|
|
27
|
+
this.updated_at = updated_at;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static createByProps(props)
|
|
31
|
+
{
|
|
32
|
+
const {id, category_id, name, sku, description, price, stock_quantity, is_featured, metadata, tags, status, created_at, updated_at} = props;
|
|
33
|
+
return new this(id, category_id, name, sku, description, price, stock_quantity, is_featured, metadata, tags, status, created_at, updated_at);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const schema = new EntitySchema({
|
|
39
|
+
class: TestProductsModel,
|
|
40
|
+
tableName: 'test_products',
|
|
41
|
+
properties: {
|
|
42
|
+
id: { type: 'number', primary: true },
|
|
43
|
+
category_id: { type: 'number', persist: false },
|
|
44
|
+
name: { type: 'string' },
|
|
45
|
+
sku: { type: 'string' },
|
|
46
|
+
description: { type: 'string', nullable: true },
|
|
47
|
+
price: { type: 'number' },
|
|
48
|
+
stock_quantity: { type: 'number', nullable: true },
|
|
49
|
+
is_featured: { type: 'number', nullable: true },
|
|
50
|
+
metadata: { type: 'object', nullable: true },
|
|
51
|
+
tags: { type: 'string', nullable: true },
|
|
52
|
+
status: { type: 'undefined', nullable: true },
|
|
53
|
+
created_at: { type: 'Date', nullable: true },
|
|
54
|
+
updated_at: { type: 'Date', nullable: true },
|
|
55
|
+
related_test_categories: {
|
|
56
|
+
kind: 'm:1',
|
|
57
|
+
entity: 'TestCategoriesModel',
|
|
58
|
+
joinColumn: 'category_id'
|
|
59
|
+
},
|
|
60
|
+
related_test_reviews: {
|
|
61
|
+
kind: '1:m',
|
|
62
|
+
entity: 'TestReviewsModel',
|
|
63
|
+
mappedBy: 'related_test_products'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
schema._fkMappings = {
|
|
68
|
+
"category_id": {
|
|
69
|
+
"relationKey": "related_test_categories",
|
|
70
|
+
"entityName": "TestCategoriesModel",
|
|
71
|
+
"referencedColumn": "id",
|
|
72
|
+
"nullable": false
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
module.exports = {
|
|
76
|
+
TestProductsModel,
|
|
77
|
+
entity: TestProductsModel,
|
|
78
|
+
schema: schema
|
|
79
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - TestReviewsModel
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { MikroOrmCore } = require('../../../index');
|
|
8
|
+
const { EntitySchema } = MikroOrmCore;
|
|
9
|
+
|
|
10
|
+
class TestReviewsModel
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
constructor(id, product_id, reviewer_name, reviewer_email, rating, title, comment, is_verified, helpful_count, created_at, updated_at)
|
|
14
|
+
{
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.product_id = product_id;
|
|
17
|
+
this.reviewer_name = reviewer_name;
|
|
18
|
+
this.reviewer_email = reviewer_email;
|
|
19
|
+
this.rating = rating;
|
|
20
|
+
this.title = title;
|
|
21
|
+
this.comment = comment;
|
|
22
|
+
this.is_verified = is_verified;
|
|
23
|
+
this.helpful_count = helpful_count;
|
|
24
|
+
this.created_at = created_at;
|
|
25
|
+
this.updated_at = updated_at;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static createByProps(props)
|
|
29
|
+
{
|
|
30
|
+
const {id, product_id, reviewer_name, reviewer_email, rating, title, comment, is_verified, helpful_count, created_at, updated_at} = props;
|
|
31
|
+
return new this(id, product_id, reviewer_name, reviewer_email, rating, title, comment, is_verified, helpful_count, created_at, updated_at);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const schema = new EntitySchema({
|
|
37
|
+
class: TestReviewsModel,
|
|
38
|
+
tableName: 'test_reviews',
|
|
39
|
+
properties: {
|
|
40
|
+
id: { type: 'number', primary: true },
|
|
41
|
+
product_id: { type: 'number', persist: false },
|
|
42
|
+
reviewer_name: { type: 'string' },
|
|
43
|
+
reviewer_email: { type: 'string' },
|
|
44
|
+
rating: { type: 'number' },
|
|
45
|
+
title: { type: 'string', nullable: true },
|
|
46
|
+
comment: { type: 'string', nullable: true },
|
|
47
|
+
is_verified: { type: 'number', nullable: true },
|
|
48
|
+
helpful_count: { type: 'number', nullable: true },
|
|
49
|
+
created_at: { type: 'Date', nullable: true },
|
|
50
|
+
updated_at: { type: 'Date', nullable: true },
|
|
51
|
+
related_test_products: {
|
|
52
|
+
kind: 'm:1',
|
|
53
|
+
entity: 'TestProductsModel',
|
|
54
|
+
joinColumn: 'product_id'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
schema._fkMappings = {
|
|
59
|
+
"product_id": {
|
|
60
|
+
"relationKey": "related_test_products",
|
|
61
|
+
"entityName": "TestProductsModel",
|
|
62
|
+
"referencedColumn": "id",
|
|
63
|
+
"nullable": false
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
module.exports = {
|
|
67
|
+
TestReviewsModel,
|
|
68
|
+
entity: TestReviewsModel,
|
|
69
|
+
schema: schema
|
|
70
|
+
};
|