@storecraft/database-mongodb 1.0.20 → 1.2.5
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 +7 -7
- package/index.js +22 -39
- package/migrate.js +0 -1
- package/migrations/00005_add_chats_collection.js +57 -0
- package/package.json +1 -2
- package/src/con.auth_users.js +3 -15
- package/src/con.chats.js +119 -0
- package/src/con.collections.js +2 -11
- package/src/con.customers.js +5 -14
- package/src/con.discounts.js +6 -11
- package/src/con.discounts.utils.js +2 -3
- package/src/con.images.js +9 -17
- package/src/con.notifications.js +4 -11
- package/src/con.orders.js +4 -7
- package/src/con.posts.js +0 -15
- package/src/con.products.js +1 -9
- package/src/con.search.js +28 -14
- package/src/con.shared.js +23 -45
- package/src/con.shipping.js +0 -7
- package/src/con.storefronts.js +6 -9
- package/src/con.tags.js +7 -11
- package/src/con.templates.js +4 -8
- package/src/utils.funcs.js +5 -6
- package/src/utils.query.js +165 -140
- package/src/utils.query_OLD.js +189 -0
- package/src/utils.relations.js +43 -76
- package/tests/runner.test.js +9 -5
- package/tests/sandbox.js +5 -5
- package/vector-store/index.js +44 -10
- package/tests/query.cursor.test.js +0 -389
- package/tests/query.vql.test.js +0 -71
package/src/con.images.js
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
/**
|
2
2
|
* @import { db_images as db_col } from '@storecraft/core/database'
|
3
3
|
* @import { ImageType } from '@storecraft/core/api'
|
4
|
-
* @import {
|
4
|
+
* @import { AnyBulkWriteOperation } from 'mongodb'
|
5
5
|
*/
|
6
|
-
|
7
6
|
import { Collection } from 'mongodb'
|
8
7
|
import { MongoDB } from '../index.js'
|
9
|
-
import {
|
10
|
-
|
8
|
+
import {
|
9
|
+
count_regular, get_regular, list_regular,
|
10
|
+
upsert_regular
|
11
|
+
} from './con.shared.js'
|
11
12
|
import { handle_or_id, to_objid } from './utils.funcs.js';
|
12
13
|
import { func } from '@storecraft/core/api';
|
13
14
|
import { ID } from '@storecraft/core/api/utils.func.js';
|
@@ -34,8 +35,6 @@ const get = (driver) => get_regular(driver, col(driver));
|
|
34
35
|
|
35
36
|
/**
|
36
37
|
* @param {MongoDB} driver
|
37
|
-
*
|
38
|
-
*
|
39
38
|
* @returns {db_col["remove"]}
|
40
39
|
*/
|
41
40
|
const remove = (driver) => {
|
@@ -85,12 +84,8 @@ const remove = (driver) => {
|
|
85
84
|
}
|
86
85
|
|
87
86
|
/**
|
88
|
-
* report media usages
|
89
|
-
*
|
90
|
-
*
|
87
|
+
* @description report media usages
|
91
88
|
* @param {MongoDB} driver
|
92
|
-
*
|
93
|
-
*
|
94
89
|
* @returns {db_col["report_document_media"]}
|
95
90
|
*/
|
96
91
|
export const report_document_media = (driver) => {
|
@@ -99,15 +94,14 @@ export const report_document_media = (driver) => {
|
|
99
94
|
return;
|
100
95
|
|
101
96
|
const add_to_search_index = func.union(
|
102
|
-
data['title'],
|
97
|
+
data['title'],
|
98
|
+
func.to_tokens(data['title'])
|
103
99
|
);
|
104
100
|
|
105
101
|
const dates = func.apply_dates({});
|
106
102
|
|
107
103
|
/**
|
108
104
|
* @param {string} url
|
109
|
-
*
|
110
|
-
*
|
111
105
|
* @returns {AnyBulkWriteOperation<ImageType>}
|
112
106
|
*/
|
113
107
|
const url_to_update = url => {
|
@@ -156,10 +150,8 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
156
150
|
|
157
151
|
/**
|
158
152
|
* @param {MongoDB} driver
|
159
|
-
*
|
160
|
-
*
|
161
153
|
* @return {db_col & { _col: ReturnType<col>}}
|
162
|
-
|
154
|
+
*/
|
163
155
|
export const impl = (driver) => {
|
164
156
|
|
165
157
|
return {
|
package/src/con.notifications.js
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
/**
|
2
2
|
* @import { db_notifications as db_col } from '@storecraft/core/database'
|
3
3
|
*/
|
4
|
-
|
5
4
|
import { Collection } from 'mongodb'
|
6
5
|
import { MongoDB } from '../index.js'
|
7
|
-
import {
|
8
|
-
|
6
|
+
import {
|
7
|
+
count_regular, get_regular, list_regular,
|
8
|
+
remove_regular,
|
9
|
+
} from './con.shared.js'
|
9
10
|
import { to_objid } from './utils.funcs.js';
|
10
11
|
import { add_search_terms_relation_on } from './utils.relations.js';
|
11
12
|
import { union } from '@storecraft/core/api/utils.func.js';
|
12
13
|
|
13
14
|
/**
|
14
15
|
* @param {MongoDB} d
|
15
|
-
*
|
16
|
-
*
|
17
16
|
* @returns {Collection<db_col["$type_get"]>}
|
18
17
|
*/
|
19
18
|
const col = (d) => d.collection('notifications');
|
20
19
|
|
21
20
|
/**
|
22
21
|
* @param {MongoDB} driver
|
23
|
-
*
|
24
22
|
* @returns {db_col["upsert"]}
|
25
23
|
*/
|
26
24
|
const upsert = (driver) => {
|
@@ -29,11 +27,8 @@ const upsert = (driver) => {
|
|
29
27
|
}
|
30
28
|
}
|
31
29
|
|
32
|
-
|
33
30
|
/**
|
34
31
|
* @param {MongoDB} driver
|
35
|
-
*
|
36
|
-
*
|
37
32
|
* @returns {db_col["upsertBulk"]}
|
38
33
|
*/
|
39
34
|
const upsertBulk = (driver) => {
|
@@ -84,8 +79,6 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
84
79
|
|
85
80
|
/**
|
86
81
|
* @param {MongoDB} driver
|
87
|
-
*
|
88
|
-
*
|
89
82
|
* @return {db_col & { _col: ReturnType<col>}}
|
90
83
|
*/
|
91
84
|
export const impl = (driver) => {
|
package/src/con.orders.js
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
/**
|
2
2
|
* @import { db_orders as db_col } from '@storecraft/core/database'
|
3
3
|
*/
|
4
|
-
|
5
4
|
import { Collection } from 'mongodb'
|
6
5
|
import { MongoDB } from '../index.js'
|
7
|
-
import {
|
8
|
-
|
6
|
+
import {
|
7
|
+
count_regular, get_regular, list_regular,
|
8
|
+
remove_regular, upsert_regular
|
9
|
+
} from './con.shared.js'
|
9
10
|
|
10
11
|
/**
|
11
12
|
* @param {MongoDB} d
|
12
|
-
*
|
13
|
-
*
|
14
13
|
* @returns {Collection<db_col["$type_get"]>}
|
15
14
|
*/
|
16
15
|
const col = (d) => d.collection('orders');
|
@@ -44,8 +43,6 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
44
43
|
|
45
44
|
/**
|
46
45
|
* @param {MongoDB} driver
|
47
|
-
*
|
48
|
-
*
|
49
46
|
* @return {db_col & { _col: ReturnType<col>}}
|
50
47
|
*/
|
51
48
|
export const impl = (driver) => {
|
package/src/con.posts.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
* @import { db_posts as db_col } from '@storecraft/core/database'
|
3
3
|
* @import { WithRelations } from './utils.types.js'
|
4
4
|
*/
|
5
|
-
|
6
5
|
import { Collection } from 'mongodb'
|
7
6
|
import { MongoDB } from '../index.js'
|
8
7
|
import { count_regular, get_regular, list_regular } from './con.shared.js'
|
@@ -14,23 +13,14 @@ import {
|
|
14
13
|
update_entry_on_all_connection_of_relation
|
15
14
|
} from './utils.relations.js';
|
16
15
|
|
17
|
-
|
18
|
-
/**
|
19
|
-
* @typedef {import('@storecraft/core/database').db_posts} db_col
|
20
|
-
*/
|
21
|
-
|
22
16
|
/**
|
23
17
|
* @param {MongoDB} d
|
24
|
-
*
|
25
|
-
*
|
26
18
|
* @returns {Collection<WithRelations<db_col["$type_get"]>>}
|
27
19
|
*/
|
28
20
|
const col = (d) => d.collection('posts');
|
29
21
|
|
30
22
|
/**
|
31
23
|
* @param {MongoDB} driver
|
32
|
-
*
|
33
|
-
*
|
34
24
|
* @returns {db_col["upsert"]}
|
35
25
|
*/
|
36
26
|
const upsert = (driver) => {
|
@@ -49,7 +39,6 @@ const upsert = (driver) => {
|
|
49
39
|
////
|
50
40
|
// STOREFRONTS --> POSTS RELATION
|
51
41
|
////
|
52
|
-
|
53
42
|
await update_entry_on_all_connection_of_relation(
|
54
43
|
driver, 'storefronts', 'posts', objid, data, session
|
55
44
|
);
|
@@ -82,8 +71,6 @@ const get = (driver) => get_regular(driver, col(driver));
|
|
82
71
|
|
83
72
|
/**
|
84
73
|
* @param {MongoDB} driver
|
85
|
-
*
|
86
|
-
*
|
87
74
|
* @returns {db_col["remove"]}
|
88
75
|
*/
|
89
76
|
const remove = (driver) => {
|
@@ -137,8 +124,6 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
137
124
|
|
138
125
|
/**
|
139
126
|
* @param {MongoDB} driver
|
140
|
-
*
|
141
|
-
*
|
142
127
|
* @return {db_col & { _col: ReturnType<col>}}
|
143
128
|
*/
|
144
129
|
export const impl = (driver) => {
|
package/src/con.products.js
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
* @import { db_products as db_col, RegularGetOptions } from '@storecraft/core/database'
|
3
3
|
* @import { ProductType, VariantType } from '@storecraft/core/api'
|
4
4
|
* @import { WithRelations } from './utils.types.js'
|
5
|
-
* @import {
|
5
|
+
* @import { AnyBulkWriteOperation } from 'mongodb'
|
6
6
|
*/
|
7
|
-
|
8
7
|
import { Collection } from 'mongodb'
|
9
8
|
import { MongoDB } from '../index.js'
|
10
9
|
import {
|
@@ -38,16 +37,12 @@ import {
|
|
38
37
|
|
39
38
|
/**
|
40
39
|
* @param {MongoDB} d
|
41
|
-
*
|
42
|
-
*
|
43
40
|
* @returns {Collection<WithRelations<db_col["$type_get"]>>}
|
44
41
|
*/
|
45
42
|
const col = (d) => d.collection('products');
|
46
43
|
|
47
44
|
/**
|
48
45
|
* @param {MongoDB} driver
|
49
|
-
*
|
50
|
-
*
|
51
46
|
* @returns {db_col["upsert"]}
|
52
47
|
*/
|
53
48
|
const upsert = (driver) => {
|
@@ -206,15 +201,12 @@ const upsert = (driver) => {
|
|
206
201
|
|
207
202
|
|
208
203
|
/**
|
209
|
-
*
|
210
204
|
* @param {MongoDB} driver
|
211
205
|
*/
|
212
206
|
const get = (driver) => get_regular(driver, col(driver));
|
213
207
|
|
214
208
|
/**
|
215
209
|
* @param {MongoDB} driver
|
216
|
-
*
|
217
|
-
*
|
218
210
|
* @returns {db_col["remove"]}
|
219
211
|
*/
|
220
212
|
const remove = (driver) => {
|
package/src/con.search.js
CHANGED
@@ -2,11 +2,9 @@
|
|
2
2
|
* @import { search as db_col, db_driver } from '@storecraft/core/database'
|
3
3
|
* @import { QuickSearchResource, QuickSearchResult } from '@storecraft/core/api'
|
4
4
|
*/
|
5
|
-
|
6
5
|
import { MongoDB } from '../index.js'
|
7
6
|
import { query_to_mongo } from './utils.query.js';
|
8
7
|
|
9
|
-
|
10
8
|
/**
|
11
9
|
* @type {(keyof db_driver["resources"])[]}
|
12
10
|
*/
|
@@ -22,7 +20,8 @@ const tables = [
|
|
22
20
|
'notifications',
|
23
21
|
'discounts',
|
24
22
|
'orders',
|
25
|
-
'templates'
|
23
|
+
'templates',
|
24
|
+
'chats'
|
26
25
|
]
|
27
26
|
|
28
27
|
/**
|
@@ -42,13 +41,27 @@ const prefix_to_resource = {
|
|
42
41
|
'tag': 'tags',
|
43
42
|
'template': 'templates',
|
44
43
|
'post': 'posts',
|
45
|
-
|
44
|
+
'chat': 'chats',
|
45
|
+
}
|
46
|
+
|
47
|
+
const resource_to_props = {
|
48
|
+
'auth_users': ['id', 'handle'],
|
49
|
+
'collections': ['id', 'handle'],
|
50
|
+
'customers': ['id', 'handle'],
|
51
|
+
'discounts': ['id', 'handle', 'title'],
|
52
|
+
'images': ['id', 'handle', 'name'],
|
53
|
+
'orders': ['id'],
|
54
|
+
'products': ['id', 'handle', 'title'],
|
55
|
+
'shipping_methods': ['id', 'handle', 'title'],
|
56
|
+
'storefronts': ['id', 'handle', 'title'],
|
57
|
+
'tags': ['id', 'handle'],
|
58
|
+
'templates': ['id', 'handle', 'title'],
|
59
|
+
'posts': ['id', 'handle', 'title'],
|
60
|
+
'chats': ['id', 'customer_email', 'customer_id'],
|
46
61
|
}
|
47
62
|
|
48
63
|
/**
|
49
|
-
*
|
50
64
|
* @param {string} id
|
51
|
-
*
|
52
65
|
* @returns {keyof db_driver["resources"]}
|
53
66
|
*/
|
54
67
|
export const id_to_resource = id => {
|
@@ -65,8 +78,6 @@ export const id_to_resource = id => {
|
|
65
78
|
|
66
79
|
/**
|
67
80
|
* @param {MongoDB} driver
|
68
|
-
*
|
69
|
-
*
|
70
81
|
* @returns {db_col["quicksearch"]}
|
71
82
|
*/
|
72
83
|
export const quicksearch = (driver) => {
|
@@ -93,10 +104,15 @@ export const quicksearch = (driver) => {
|
|
93
104
|
},
|
94
105
|
{
|
95
106
|
$project: {
|
96
|
-
title: 1,
|
97
|
-
handle: 1,
|
98
|
-
// '_relations.search': 1,
|
99
107
|
id: 1,
|
108
|
+
handle: 1,
|
109
|
+
|
110
|
+
title: 1,
|
111
|
+
name: 1,
|
112
|
+
|
113
|
+
customer_email: 1,
|
114
|
+
customer_id: 1,
|
115
|
+
|
100
116
|
_id: 0
|
101
117
|
}
|
102
118
|
}
|
@@ -151,10 +167,8 @@ export const quicksearch = (driver) => {
|
|
151
167
|
|
152
168
|
/**
|
153
169
|
* @param {MongoDB} driver
|
154
|
-
*
|
155
|
-
*
|
156
170
|
* @return {db_col}
|
157
|
-
|
171
|
+
*/
|
158
172
|
export const impl = (driver) => {
|
159
173
|
|
160
174
|
return {
|
package/src/con.shared.js
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
/**
|
2
|
-
* @import { db_crud,
|
3
|
-
* @import {
|
4
|
-
*
|
2
|
+
* @import { db_crud, withConcreteId, withConcreteIdAndHandle } from '@storecraft/core/database'
|
3
|
+
* @import {
|
4
|
+
* BaseType, ExpandQuery, withOptionalID
|
5
|
+
* } from '@storecraft/core/api'
|
5
6
|
* @import { WithRelations } from './utils.types.js'
|
6
7
|
* @import { WithId } from 'mongodb'
|
7
8
|
*/
|
8
|
-
|
9
9
|
import { Collection } from 'mongodb'
|
10
10
|
import { MongoDB } from '../index.js'
|
11
|
-
import {
|
12
|
-
|
11
|
+
import {
|
12
|
+
handle_or_id, isUndef, sanitize_array,
|
13
|
+
sanitize_one, to_objid
|
14
|
+
} from './utils.funcs.js'
|
13
15
|
import { query_to_mongo } from './utils.query.js'
|
14
16
|
import { report_document_media } from './con.images.js'
|
15
17
|
import { add_search_terms_relation_on } from './utils.relations.js'
|
16
18
|
|
17
19
|
|
18
20
|
/**
|
19
|
-
* @
|
20
|
-
* @template {
|
21
|
-
*
|
21
|
+
* @description Upsert function for MongoDB
|
22
|
+
* @template {Partial<withConcreteIdAndHandle<{}>>} T
|
23
|
+
* @template {Partial<withConcreteIdAndHandle<{}>>} G
|
22
24
|
* @param {MongoDB} driver
|
23
25
|
* @param {Collection<G>} col
|
24
|
-
*
|
25
26
|
* @returns {db_crud<T, G>["upsert"]}
|
26
27
|
*/
|
27
28
|
export const upsert_regular = (driver, col) => {
|
@@ -72,20 +73,6 @@ export const upsert_regular = (driver, col) => {
|
|
72
73
|
|
73
74
|
);
|
74
75
|
|
75
|
-
// const res = await col.replaceOne(
|
76
|
-
// // @ts-ignore
|
77
|
-
// {
|
78
|
-
// $or: [
|
79
|
-
// data.id && { _id: to_objid(data.id) },
|
80
|
-
// data.handle && { handle: data.handle }
|
81
|
-
// ].filter(Boolean)
|
82
|
-
// },
|
83
|
-
// data,
|
84
|
-
// {
|
85
|
-
// session, upsert: true
|
86
|
-
// }
|
87
|
-
// );
|
88
|
-
|
89
76
|
////
|
90
77
|
// REPORT IMAGES USAGE
|
91
78
|
////
|
@@ -105,7 +92,7 @@ export const upsert_regular = (driver, col) => {
|
|
105
92
|
}
|
106
93
|
|
107
94
|
/**
|
108
|
-
* Extract relations names from item
|
95
|
+
* @description Extract relations names from item
|
109
96
|
* @template {WithRelations<{}>} T
|
110
97
|
* @param {T} item
|
111
98
|
*/
|
@@ -114,10 +101,8 @@ export const get_relations_names = item => {
|
|
114
101
|
}
|
115
102
|
|
116
103
|
/**
|
117
|
-
* Expand relations in-place
|
118
|
-
*
|
104
|
+
* @description Expand relations in-place
|
119
105
|
* @template {any} T
|
120
|
-
*
|
121
106
|
* @param {WithRelations<T>[]} items
|
122
107
|
* @param {ExpandQuery<T>} [expand_query]
|
123
108
|
*/
|
@@ -224,7 +209,7 @@ export const get_regular = (driver, col) => {
|
|
224
209
|
}
|
225
210
|
|
226
211
|
/**
|
227
|
-
* get bulk of items, ordered, if something is missing, `undefined`
|
212
|
+
* @description get bulk of items, ordered, if something is missing, `undefined`
|
228
213
|
* should be instead
|
229
214
|
* @template {withOptionalID} T
|
230
215
|
* @template {withOptionalID} G
|
@@ -234,11 +219,10 @@ export const get_regular = (driver, col) => {
|
|
234
219
|
*/
|
235
220
|
export const get_bulk = (driver, col) => {
|
236
221
|
return async (ids, options) => {
|
237
|
-
const objids = ids
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
222
|
+
const objids = ids
|
223
|
+
.map(handle_or_id)
|
224
|
+
.map(v => ('_id' in v) ? v._id : undefined)
|
225
|
+
.filter(Boolean);
|
242
226
|
|
243
227
|
const res = /** @type {(WithRelations<WithId<G>>)[]} */ (
|
244
228
|
await col.find(
|
@@ -264,7 +248,6 @@ export const get_bulk = (driver, col) => {
|
|
264
248
|
)
|
265
249
|
);
|
266
250
|
|
267
|
-
|
268
251
|
const sanitized = /** @type {G[]} */(
|
269
252
|
/** @type {unknown} */(
|
270
253
|
sanitize_array(res)
|
@@ -273,7 +256,9 @@ export const get_bulk = (driver, col) => {
|
|
273
256
|
|
274
257
|
// now let's order them
|
275
258
|
return ids.map(
|
276
|
-
id => sanitized.find(
|
259
|
+
id => sanitized.find(
|
260
|
+
s => s.id===id || s?.['handle']===id
|
261
|
+
)
|
277
262
|
);
|
278
263
|
|
279
264
|
}
|
@@ -282,12 +267,8 @@ export const get_bulk = (driver, col) => {
|
|
282
267
|
|
283
268
|
/**
|
284
269
|
* @template T, G
|
285
|
-
*
|
286
|
-
*
|
287
270
|
* @param {MongoDB} driver
|
288
271
|
* @param {Collection<G>} col
|
289
|
-
*
|
290
|
-
*
|
291
272
|
* @returns {db_crud<T, G>["remove"]}
|
292
273
|
*/
|
293
274
|
export const remove_regular = (driver, col) => {
|
@@ -321,7 +302,8 @@ export const list_regular = (driver, col) => {
|
|
321
302
|
|
322
303
|
/** @type {WithRelations<WithId<G>>[]} */
|
323
304
|
const items = await col.find(
|
324
|
-
filter,
|
305
|
+
filter,
|
306
|
+
{
|
325
307
|
sort,
|
326
308
|
limit: reverse_sign==-1 ? query.limitToLast : query.limit,
|
327
309
|
projection: expand_to_mongo_projection(query?.expand)
|
@@ -349,12 +331,8 @@ export const list_regular = (driver, col) => {
|
|
349
331
|
/**
|
350
332
|
* @template {any} T
|
351
333
|
* @template {any} G
|
352
|
-
*
|
353
|
-
*
|
354
334
|
* @param {MongoDB} driver
|
355
335
|
* @param {Collection<G>} col
|
356
|
-
*
|
357
|
-
*
|
358
336
|
* @returns {db_crud<T, G>["count"]}
|
359
337
|
*/
|
360
338
|
export const count_regular = (driver, col) => {
|
package/src/con.shipping.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
* @import { db_shipping as db_col } from '@storecraft/core/database'
|
3
3
|
* @import { WithRelations } from './utils.types.js'
|
4
4
|
*/
|
5
|
-
|
6
5
|
import { Collection } from 'mongodb'
|
7
6
|
import { MongoDB } from '../index.js'
|
8
7
|
import { count_regular, get_regular, list_regular } from './con.shared.js'
|
@@ -22,8 +21,6 @@ const col = (d) => d.collection('shipping_methods');
|
|
22
21
|
|
23
22
|
/**
|
24
23
|
* @param {MongoDB} driver
|
25
|
-
*
|
26
|
-
*
|
27
24
|
* @returns {db_col["upsert"]}
|
28
25
|
*/
|
29
26
|
const upsert = (driver) => {
|
@@ -79,8 +76,6 @@ const get = (driver) => get_regular(driver, col(driver));
|
|
79
76
|
|
80
77
|
/**
|
81
78
|
* @param {MongoDB} driver
|
82
|
-
*
|
83
|
-
*
|
84
79
|
* @returns {db_col["remove"]}
|
85
80
|
*/
|
86
81
|
const remove = (driver) => {
|
@@ -136,8 +131,6 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
136
131
|
|
137
132
|
/**
|
138
133
|
* @param {MongoDB} driver
|
139
|
-
*
|
140
|
-
*
|
141
134
|
* @return {db_col & { _col: ReturnType<col>}}
|
142
135
|
*/
|
143
136
|
export const impl = (driver) => {
|
package/src/con.storefronts.js
CHANGED
@@ -5,12 +5,13 @@
|
|
5
5
|
* @import { StorefrontType } from '@storecraft/core/api'
|
6
6
|
* @import { WithRelations } from './utils.types.js'
|
7
7
|
*/
|
8
|
-
|
9
8
|
import { Collection } from 'mongodb'
|
10
9
|
import { MongoDB } from '../index.js'
|
11
|
-
import {
|
12
|
-
|
13
|
-
|
10
|
+
import {
|
11
|
+
count_regular, expand, get_regular, list_regular,
|
12
|
+
remove_regular
|
13
|
+
} from './con.shared.js'
|
14
|
+
import { sanitize_recursively, to_objid } from './utils.funcs.js'
|
14
15
|
import {
|
15
16
|
add_search_terms_relation_on, create_explicit_relation, save_me
|
16
17
|
} from './utils.relations.js';
|
@@ -24,8 +25,6 @@ const col = (d) => d.collection('storefronts');
|
|
24
25
|
|
25
26
|
/**
|
26
27
|
* @param {MongoDB} driver
|
27
|
-
*
|
28
|
-
*
|
29
28
|
* @return {db_col["upsert"]}
|
30
29
|
*/
|
31
30
|
const upsert = (driver) => {
|
@@ -223,10 +222,8 @@ const get_default_auto_generated_storefront = (driver) => {
|
|
223
222
|
|
224
223
|
/**
|
225
224
|
* @param {MongoDB} driver
|
226
|
-
*
|
227
|
-
*
|
228
225
|
* @return {db_col & { _col: ReturnType<col>}}
|
229
|
-
|
226
|
+
*/
|
230
227
|
export const impl = (driver) => {
|
231
228
|
|
232
229
|
return {
|
package/src/con.tags.js
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
/**
|
2
2
|
* @import { db_tags as db_col } from '@storecraft/core/database'
|
3
3
|
*/
|
4
|
-
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
|
8
|
-
remove_regular, upsert_regular
|
4
|
+
import { Collection } from 'mongodb';
|
5
|
+
import { MongoDB } from '../index.js';
|
6
|
+
import {
|
7
|
+
count_regular, get_regular, list_regular,
|
8
|
+
remove_regular, upsert_regular
|
9
|
+
} from './con.shared.js';
|
9
10
|
|
10
11
|
/**
|
11
12
|
* @param {MongoDB} d
|
12
|
-
*
|
13
|
-
*
|
14
13
|
* @returns {Collection<db_col["$type_get"]>}
|
15
14
|
*/
|
16
15
|
const col = (d) => d.collection('tags');
|
17
16
|
|
18
17
|
/**
|
19
18
|
* @param {MongoDB} driver
|
20
|
-
*
|
21
19
|
* @returns {db_col["upsert"]}
|
22
20
|
*/
|
23
21
|
const upsert = (driver) => upsert_regular(driver, col(driver));
|
@@ -44,10 +42,8 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
44
42
|
|
45
43
|
/**
|
46
44
|
* @param {MongoDB} driver
|
47
|
-
*
|
48
|
-
*
|
49
45
|
* @return {db_col & { _col: ReturnType<col>}}
|
50
|
-
|
46
|
+
*/
|
51
47
|
export const impl = (driver) => {
|
52
48
|
|
53
49
|
return {
|
package/src/con.templates.js
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
/**
|
2
2
|
* @import { db_templates as db_col } from '@storecraft/core/database'
|
3
3
|
*/
|
4
|
-
|
5
4
|
import { Collection } from 'mongodb'
|
6
5
|
import { MongoDB } from '../index.js'
|
7
|
-
import {
|
8
|
-
|
6
|
+
import {
|
7
|
+
count_regular, get_regular, list_regular,
|
8
|
+
remove_regular, upsert_regular
|
9
|
+
} from './con.shared.js'
|
9
10
|
|
10
11
|
/**
|
11
12
|
* @param {MongoDB} d
|
12
|
-
*
|
13
|
-
*
|
14
13
|
* @returns {Collection<db_col["$type_get"]>}
|
15
14
|
*/
|
16
15
|
const col = (d) => d.collection('templates');
|
17
16
|
|
18
17
|
/**
|
19
18
|
* @param {MongoDB} driver
|
20
|
-
*
|
21
19
|
* @returns {db_col["upsert"]}
|
22
20
|
*/
|
23
21
|
const upsert = (driver) => upsert_regular(driver, col(driver));
|
@@ -44,8 +42,6 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
44
42
|
|
45
43
|
/**
|
46
44
|
* @param {MongoDB} driver
|
47
|
-
*
|
48
|
-
*
|
49
45
|
* @return {db_col & { _col: ReturnType<col>}}
|
50
46
|
* */
|
51
47
|
export const impl = (driver) => {
|