From 70e6a45d065eddabc258d71ed4c9f5e03c06ba25 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 13 Nov 2022 18:29:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/utils/index.ts b/src/utils/index.ts index 511d45f..f023c10 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -45,6 +45,36 @@ export const getTable: any = ({ env,tableName, okFun }: Typeint) => { }); }; + // 更新数据 +export const updateTableid: any = ({ env,tableName,objData, id, okFun }: Typeint) => { + // 数据库环境 + const db: any = Taro.cloud.database({ + env: env, + }); + let nowtable: any = db?.collection(tableName); + nowtable.doc(id).update({ + // data 传入需要局部更新的数据 + data: objData, + success: (res: any) => { + okFun(res); + }, + }) + }; + + // 删除数据 +export const deleteTableid: any = ({ env,tableName, id, okFun }: Typeint) => { + // 数据库环境 + const db: any = Taro.cloud.database({ + env: env, + }); + let nowtable: any = db?.collection(tableName); + nowtable.doc(id).remove({ + success: (res: any) => { + okFun(res); + }, + }) + }; + // 获取指定id数据数据