Skip to content

Commit

Permalink
Merge pull request #2 from moleculerjs/master
Browse files Browse the repository at this point in the history
merge from origin
  • Loading branch information
maxinminax authored Jun 28, 2023
2 parents e1ac4da + 3e962ec commit b2582f1
Show file tree
Hide file tree
Showing 6 changed files with 12,729 additions and 9,434 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<a name="v0.1.1"></a>

# [0.1.1](https://github.com/moleculerjs/database/compare/v0.1.0...v0.1.1) (2023-04-23)

- fix permission/permissive type [#31](https://github.com/moleculerjs/moleculer-channels/pull/31)
- fix TypeError `createFromHexString` [#40](https://github.com/moleculerjs/moleculer-channels/pull/40)
- fix waiting for adapter in connecting state [#2d9888e](https://github.com/moleculerjs/database/commit/2d9888e497363ac88aa3b62c354d680d53b3213b)

<a name="v0.1.0"></a>

# v0.1.0 (2022-10-02)

First public version.
78 changes: 78 additions & 0 deletions examples/connect/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* eslint-disable no-console */
"use strict";

/**
* It's an example to test the connect/disconnect logic of adapters.
*/

const { ServiceBroker } = require("moleculer");
const { inspect } = require("util");
const DbService = require("../../index").Service;

// Create broker
const broker = new ServiceBroker({
logger: {
type: "Console",
options: {
level: {
POSTS: "debug",
"*": "info"
},
objectPrinter: obj =>
inspect(obj, {
breakLength: 50,
colors: true,
depth: 3
})
}
}
});

// Create a service
broker.createService({
name: "posts",
mixins: [
DbService({
adapter: {
type: "MongoDB"
}
})
],

settings: {
fields: {
id: { type: "string", primaryKey: true, columnName: "_id" },
title: {
type: "string",
max: 255,
trim: true,
required: true
},
content: { type: "string" },
votes: { type: "number", integer: true, min: 0, default: 0, columnType: "int" },
status: { type: "boolean", default: true }
}
},

async started() {
this.logger.info("Creating multiple adapters...");
const adapters = await Promise.all([
this.getAdapter(),
this.getAdapter(),
this.getAdapter()
]);
this.logger.info(
"Adapters created.",
adapters.map(a => a.constructor.name)
);
}
});

// Start server
broker
.start()
.then(() => broker.repl())
.catch(err => {
broker.logger.error(err);
process.exit(1);
});
Loading

0 comments on commit b2582f1

Please sign in to comment.