@storecraft/database-mongodb 1.0.6 → 1.0.8
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 -2
- package/migrations/00000_init_tables.js +4 -3
- package/package.json +3 -2
- package/tests/runner.test.js +11 -1
package/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
width='90%' />
|
6
6
|
</div><hr/><br/>
|
7
7
|
|
8
|
-
Official `mongodb` driver for `StoreCraft` on **Node.js** platforms.
|
8
|
+
Official `mongodb` driver for `StoreCraft` on **Node.js** / **Deno** / **Bun** platforms.
|
9
9
|
|
10
10
|
```bash
|
11
11
|
npm i @storecraft/database-mongodb
|
@@ -44,4 +44,4 @@ const server = http.createServer(app.handler).listen(
|
|
44
44
|
|
45
45
|
```text
|
46
46
|
Author: Tomer Shalev <tomer.shalev@gmail.com>
|
47
|
-
```
|
47
|
+
```
|
@@ -16,10 +16,11 @@ export async function up(db, client) {
|
|
16
16
|
|
17
17
|
const session = client.startSession();
|
18
18
|
try {
|
19
|
-
await session.withTransaction(async () => {
|
19
|
+
await session.withTransaction(async ($session) => {
|
20
20
|
for (const collection_name of collections) {
|
21
21
|
|
22
|
-
await db.
|
22
|
+
await db.createCollection(collection_name, {session: $session})
|
23
|
+
await db.collection(collection_name).dropIndexes({ session: $session });
|
23
24
|
|
24
25
|
await db.collection(collection_name).createIndexes(
|
25
26
|
[
|
@@ -40,7 +41,7 @@ export async function up(db, client) {
|
|
40
41
|
background: false, sparse: true
|
41
42
|
},
|
42
43
|
], {
|
43
|
-
session
|
44
|
+
session: $session
|
44
45
|
}
|
45
46
|
)
|
46
47
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/database-mongodb",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8",
|
4
4
|
"description": "Storecraft database driver for mongodb on node / bun / deno platform",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
@@ -22,7 +22,8 @@
|
|
22
22
|
"scripts": {
|
23
23
|
"database-mongodb:test": "node ./tests/runner.test.js",
|
24
24
|
"test": "npm run database-mongodb:test",
|
25
|
-
"prepublishOnly": "npm version patch --force"
|
25
|
+
"prepublishOnly": "npm version patch --force",
|
26
|
+
"sc-publish": "npm publish"
|
26
27
|
},
|
27
28
|
"dependencies": {
|
28
29
|
"@storecraft/core": "^1.0.0",
|
package/tests/runner.test.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import 'dotenv/config';
|
1
2
|
import { App } from '@storecraft/core';
|
2
3
|
import { MongoDB, migrateToLatest } from '@storecraft/database-mongodb';
|
3
4
|
import { NodePlatform } from '@storecraft/core/platform/node';
|
@@ -12,7 +13,14 @@ export const create_app = async () => {
|
|
12
13
|
}
|
13
14
|
)
|
14
15
|
.withPlatform(new NodePlatform())
|
15
|
-
.withDatabase(
|
16
|
+
.withDatabase(
|
17
|
+
new MongoDB(
|
18
|
+
{
|
19
|
+
db_name: 'test222',//process.env.MONGODB_NAME,
|
20
|
+
url: process.env.MONGODB_URL
|
21
|
+
}
|
22
|
+
)
|
23
|
+
)
|
16
24
|
|
17
25
|
return app.init();
|
18
26
|
}
|
@@ -22,6 +30,8 @@ async function test() {
|
|
22
30
|
|
23
31
|
await migrateToLatest(app.db, false);
|
24
32
|
|
33
|
+
// api.collections_list.create(app).run();
|
34
|
+
|
25
35
|
Object.entries(api).slice(0, -1).forEach(
|
26
36
|
([name, runner]) => {
|
27
37
|
runner.create(app).run();
|