forked from moleculerjs/database
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from moleculerjs/master
merge from origin
- Loading branch information
Showing
6 changed files
with
12,729 additions
and
9,434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
Oops, something went wrong.