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数据数据