From b0e14226787d2bf8f11e7a935db58f318cc9f9da Mon Sep 17 00:00:00 2001 From: Alex Lee <3076438032@qq.com> Date: Thu, 25 Apr 2024 01:01:13 +0800 Subject: [PATCH] Update login.md --- docs/zh/quick-start/login.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/zh/quick-start/login.md b/docs/zh/quick-start/login.md index befa7f942f..02b313ed4a 100644 --- a/docs/zh/quick-start/login.md +++ b/docs/zh/quick-start/login.md @@ -27,6 +27,8 @@ import cloud from "@lafjs/cloud"; import { createHash } from "crypto"; +const db = cloud.mongo.db + export default async function (ctx: FunctionContext) { const username = ctx.body?.username || ""; const password = ctx.body?.password || ""; @@ -38,7 +40,6 @@ export default async function (ctx: FunctionContext) { return { error: "invalid password" }; // check username existed - const db = cloud.database(); const exists = await db .collection("users") .where({ username: username }) @@ -68,12 +69,13 @@ export default async function (ctx: FunctionContext) { import cloud from "@lafjs/cloud"; import { createHash } from "crypto"; +const db = cloud.mongo.db + export default async function (ctx: FunctionContext) { const username = ctx.body?.username || ""; const password = ctx.body?.password || ""; // check user login - const db = cloud.database(); const res = await db .collection("users") .where({