@storecraft/database-mongodb 1.0.8 → 1.0.10

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,6 +5,8 @@
5
5
  width='90%' />
6
6
  </div><hr/><br/>
7
7
 
8
+ [![MongoDB](https://github.com/store-craft/storecraft/actions/workflows/test.database-mongodb.yml/badge.svg)](https://github.com/store-craft/storecraft/actions/workflows/test.database-mongodb.yml)
9
+
8
10
  Official `mongodb` driver for `StoreCraft` on **Node.js** / **Deno** / **Bun** platforms.
9
11
 
10
12
  ```bash
@@ -18,7 +20,7 @@ import 'dotenv/config';
18
20
  import http from "node:http";
19
21
  import { App } from '@storecraft/core'
20
22
  import { NodePlatform } from '@storecraft/core/platform/node';
21
- import { MongoDB } from '@storecraft/database-mongodb'
23
+ import { MongoDB, migrateToLatest } from '@storecraft/database-mongodb'
22
24
  import { NodeLocalStorage } from '@storecraft/core/storage/node'
23
25
 
24
26
  const app = new App(
@@ -29,10 +31,11 @@ const app = new App(
29
31
  }
30
32
  )
31
33
  .withPlatform(new NodePlatform())
32
- .withDatabase(new MongoDB({ db_name: 'test'}))
34
+ .withDatabase(new MongoDB({ db_name: 'test', url: '...', options: {}}))
33
35
 
34
36
  await app.init();
35
-
37
+ await migrateToLatest(app.db, false);
38
+
36
39
  const server = http.createServer(app.handler).listen(
37
40
  8000,
38
41
  () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/database-mongodb",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
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)",
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(
@@ -16,8 +16,8 @@ export const create_app = async () => {
16
16
  .withDatabase(
17
17
  new MongoDB(
18
18
  {
19
- db_name: 'test222',//process.env.MONGODB_NAME,
20
- url: process.env.MONGODB_URL
19
+ db_name: process.env.MONGODB_NAME,
20
+ url: process.env.MONGODB_URL,
21
21
  }
22
22
  )
23
23
  )
@@ -30,8 +30,6 @@ async function test() {
30
30
 
31
31
  await migrateToLatest(app.db, false);
32
32
 
33
- // api.collections_list.create(app).run();
34
-
35
33
  Object.entries(api).slice(0, -1).forEach(
36
34
  ([name, runner]) => {
37
35
  runner.create(app).run();