mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: setup: fix database connection
This commit is contained in:
1 file changed
+3
-2
@@ -53,8 +53,9 @@ async function get(ctx: Context) {
|
|||||||
|
|
||||||
async function post(ctx: Context) {
|
async function post(ctx: Context) {
|
||||||
try {
|
try {
|
||||||
const url = mongoUri.parse(ctx.request.body?.url);
|
if (!ctx.request.body?.url) throw new Error('no url found');
|
||||||
const Database = await MongoClient.connect((ctx.request as any).body, {
|
const url = mongoUri.parse(ctx.request.body.url);
|
||||||
|
const Database = await MongoClient.connect(ctx.request.body.url, {
|
||||||
readPreference: 'nearest',
|
readPreference: 'nearest',
|
||||||
writeConcern: new WriteConcern('majority'),
|
writeConcern: new WriteConcern('majority'),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user