UNPKG

@sap/cds

Version:

SAP Cloud Application Programming Model - CDS for Node.js

22 lines (18 loc) 804 B
const cds = require('../index') const { resolveView, getTransition } = require('../../libx/_runtime/common/utils/resolveView') module.exports = class Resolver { constructor(service) { this.service = service } // NOTE: used in ApplicationService.handle and RemoteService.handle query(query) { return resolveView(query, this.service) } // NOTE: used in lean-draft, odata stream middleware, and cds-dbs transitions(query) { const target = query && typeof query === 'object' ? cds.infer.target(query, this.service) || query?._target : undefined const _tx = typeof tx === 'function' ? cds.context?.tx : this.service const event = query?.INSERT ? 'INSERT' : query?.UPDATE ? 'UPDATE' : query?.DELETE ? 'DELETE' : undefined return getTransition(target, _tx, event) } }