From abca5fcf87ca08bcf6ec7e8f3f2dc1f6f5618548 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Thu, 19 Dec 2024 08:11:58 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=93=8D=E4=BD=9C=EF=BC=8C=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/user/index.ts | 7 +++++-- test/user/index.ts | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/user/index.ts diff --git a/db/user/index.ts b/db/user/index.ts index 8e08470..3572d5d 100644 --- a/db/user/index.ts +++ b/db/user/index.ts @@ -4,6 +4,8 @@ import { Context } from "../../types" import { managePbError } from "../../utils/pbTools" import pbClient from "../pbClient" +const DB_NAME = "users" + // 用户接口定义 interface User { email: string @@ -25,7 +27,7 @@ export type UserModel = User & RecordModel * @returns {Promise} - 创建的用户模型 */ const create = async (user: User) => - managePbError(() => pbClient.collection("user").create(user)) + managePbError(() => pbClient.collection(DB_NAME).create(user)) /** * 通过用户ID获取用户 @@ -34,7 +36,7 @@ const create = async (user: User) => */ const getByUserId = async (userId: string) => managePbError(() => - pbClient.collection("user").getFirstListItem(`userId = "${userId}"`) + pbClient.collection(DB_NAME).getFirstListItem(`userId = "${userId}"`) ) /** @@ -76,6 +78,7 @@ const getByCtx = async ({ larkBody, larkService }: Context) => { // 用户对象 const user = { getByCtx, + getByUserId, } export default user diff --git a/test/user/index.ts b/test/user/index.ts new file mode 100644 index 0000000..298e746 --- /dev/null +++ b/test/user/index.ts @@ -0,0 +1,5 @@ +import pbClient from "../../db/pbClient" + +const userId = "zhaoyingbo" + +pbClient.collection("users").getFirstListItem(`userId = "${userId}"`)