UNPKG

@abaplint/runtime

Version:
46 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteDatabase = deleteDatabase; const prefix_1 = require("../prefix"); const types_1 = require("../types"); const insert_database_1 = require("./insert_database"); async function deleteDatabase(table, options, context) { if (options.table instanceof types_1.FieldSymbol) { options.table = options.table.getPointer(); } if (options.from instanceof types_1.FieldSymbol) { options.from = options.from.getPointer(); } if (typeof table !== "string") { table = table.get().trimEnd(); } if (options.table) { for (const row of options.table.array()) { await deleteDatabase(table, { from: row }, context); } } else if (options.from) { let where = []; const structure = options.from.get(); for (const k of Object.keys(structure)) { const str = `"${k.toLowerCase()}"` + " = " + (0, insert_database_1.toValue)(structure[k].get()); where.push(str); } where = where.join(" AND "); const { subrc, dbcnt } = await context.defaultDB().delete({ table: (0, prefix_1.buildDbTableName)(table), where, }); abap.builtin.sy.get().subrc.set(subrc); abap.builtin.sy.get().dbcnt.set(dbcnt); } else { const { subrc, dbcnt } = await context.defaultDB().delete({ table: (0, prefix_1.buildDbTableName)(table), where: options.where || "", }); abap.builtin.sy.get().subrc.set(subrc); abap.builtin.sy.get().dbcnt.set(dbcnt); } } //# sourceMappingURL=delete_database.js.map