@storecraft/database-mongodb 1.0.7 → 1.0.9

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 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.collection(collection_name).dropIndexes({ session });
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.7",
3
+ "version": "1.0.9",
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/src/con.search.js CHANGED
@@ -100,7 +100,7 @@ export const quicksearch = (driver) => {
100
100
  }
101
101
  ];
102
102
 
103
- const db = driver.mongo_client.db();
103
+ const db = driver.mongo_client.db(driver.name);
104
104
 
105
105
  /** @type {import('@storecraft/core/api').QuickSearchResource[]} */
106
106
  const items = await db.collection(tables_filtered[0]).aggregate(
@@ -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(new MongoDB({ db_name: 'test'}))
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
  }