uni-stat-error-source-map.schema.ext.js 701 字节
Newer Older
DCloud_JSON's avatar
2.1.2  
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
module.exports = {
	trigger: {
		// 监听 - 删除前
		beforeDelete: async function(obj = {}) {
			let {
				collection,
				operation,
				where,
				field
			} = obj;
			// 删除表记录前先删除云存储内的文件
			const db = uniCloud.database();
			const _ = db.command;
			let getRes = await db.collection("uni-stat-error-source-map").where(where).limit(1000).get();
			let list = getRes.data;
			if (list && list.length > 0) {
				let fileList = list.map((item, index) => {
					return item.file_id;
				});
				try {
					let deleteFileRes = await uniCloud.deleteFile({
						fileList
					});
					// console.log('deleteFileRes: ', deleteFileRes)
				} catch (err) {}
			}
		}
	}
}