@storecraft/database-mongodb 1.0.17 → 1.0.18
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.
@@ -0,0 +1,46 @@
|
|
1
|
+
import { Db, MongoClient } from 'mongodb';
|
2
|
+
import { MongoDB } from '../index.js'
|
3
|
+
import {
|
4
|
+
templates as templates_corrections
|
5
|
+
} from '@storecraft/core/assets/seed-templates-v3-update-previous-templates-with-subject.js';
|
6
|
+
|
7
|
+
/**
|
8
|
+
*
|
9
|
+
* @param {Db} db
|
10
|
+
* @param {MongoClient} client
|
11
|
+
*/
|
12
|
+
export async function up(db, client) {
|
13
|
+
|
14
|
+
const session = client.startSession();
|
15
|
+
try {
|
16
|
+
await session.withTransaction(
|
17
|
+
async (s) => {
|
18
|
+
/** @type {MongoDB} */
|
19
|
+
// @ts-ignore
|
20
|
+
const driver = client.__db_driver;
|
21
|
+
|
22
|
+
for (const template of templates_corrections) {
|
23
|
+
await driver.resources.templates._col.updateOne(
|
24
|
+
{ id: template.id },
|
25
|
+
{
|
26
|
+
$set: {
|
27
|
+
template_subject: template.template_subject,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
{ session, upsert: false }
|
31
|
+
);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
);
|
35
|
+
} finally {
|
36
|
+
await session.endSession();
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
*
|
42
|
+
* @param {Db} db
|
43
|
+
* @param {MongoClient} client
|
44
|
+
*/
|
45
|
+
export async function down(db, client) {
|
46
|
+
}
|
package/package.json
CHANGED