Skip to content

Commit

Permalink
upgrade mongodb adapter to 6.5.0 (breaking)
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Apr 1, 2024
1 parent 79b068f commit d1d1ee6
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 158 deletions.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2298,7 +2298,7 @@ module.exports = {
{
type: "MongoDB",
options: {
uri: "mongodb://localhost:27017/moleculer-demo",
uri: "mongodb://127.0.0.1:27017/moleculer-demo",
collection: `posts-${tenantId}`
}
}
Expand Down Expand Up @@ -2341,7 +2341,7 @@ module.exports = {
{
type: "MongoDB",
options: {
uri: `mongodb://localhost:27017/moleculer-demo--${tenantId}`,
uri: `mongodb://127.0.0.1:27017/moleculer-demo--${tenantId}`,
collection: `posts`
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/adapters/MongoDB.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ npm install mongodb@^4.1.4
## Usage

### Use the default localhost URI
If you not define any options, the adapter uses the `"mongodb://localhost:27017"` connection string.
If you not define any options, the adapter uses the `"mongodb://127.0.0.1:27017"` connection string.

```js
// posts.service.js
Expand Down Expand Up @@ -52,7 +52,7 @@ module.exports = {
## Options
| Property | Type | Default | Description |
| -------- | ---- | ------- | ----------- |
| `uri` | `String` | `"mongodb://localhost:27017"` | MongoDB connection URI. |
| `uri` | `String` | `"mongodb://127.0.0.1:27017"` | MongoDB connection URI. |
| `mongoClientOptions` | `Object` | `null` | Available options: https://mongodb.github.io/node-mongodb-native/4.1/interfaces/MongoClientOptions.html |
| `dbOptions` | `Object` | `null` | Available options: https://mongodb.github.io/node-mongodb-native/4.1/interfaces/DbOptions.html |

Expand Down
2 changes: 1 addition & 1 deletion examples/global-pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const broker = new ServiceBroker();

const adapter = {
type: "MongoDB",
options: "mongodb://localhost:27017/example-pool"
options: "mongodb://127.0.0.1:27017/example-pool"
};

const fields = {
Expand Down
4 changes: 2 additions & 2 deletions examples/multi-tenants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ broker.createService({
//type: "MongoDB",
type: "Knex",
options: {
//uri: "mongodb://localhost:27017",
//uri: "mongodb://127.0.0.1:27017",
//dbName: "tenants",
//collection: "posts",
tableName: "tenant_posts",
Expand Down Expand Up @@ -89,7 +89,7 @@ broker.createService({
//type: "MongoDB",
type: "Knex",
options: {
//uri: "mongodb://localhost:27017",
//uri: "mongodb://127.0.0.1:27017",
//dbName: `tenant-posts-${tenantId}`,
//collection: `posts`

Expand Down
2 changes: 1 addition & 1 deletion examples/multi-tenants/plenty.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const svc = broker.createService({
{
type: "MongoDB",
options: {
uri: "mongodb://localhost:27017",
uri: "mongodb://127.0.0.1:27017",
dbName: `tenant-posts`,
collection: `posts-${tenantId}`
}
Expand Down
25 changes: 3 additions & 22 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,16 @@ broker.createService({
mixins: [
DbService({
adapter: {
type: "Knex",
/*type: "Knex",
options: {
knex: {
client: "sqlite3",
connection: {
filename: ":memory:"
}
}
}
//type: "MongoDB"
},

createActions: {
remove: false
}*/
type: "MongoDB"
}
})
],
Expand Down Expand Up @@ -96,21 +92,6 @@ broker.createService({
}
},

actions: {
remove: {
rest: {
method: "DELETE",
path: "/:id"
},
params: {
id: { type: "string" }
},
async handler(ctx) {
console.log("Do something");
}
}
},

async started() {
const adapter = await this.getAdapter();
if (adapter.createTable) await adapter.createTable();
Expand Down
Loading

0 comments on commit d1d1ee6

Please sign in to comment.