UNPKG

ottoman

Version:
28 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pathToN1QL = void 0; const ottoman_errors_1 = require("../exceptions/ottoman-errors"); const pathToN1QL = (path) => { const fields = []; for (const { operation, expression } of path) { const { type: eType, value: eValue } = expression; switch (operation) { case 'member': { if (eType !== 'identifier') throw new ottoman_errors_1.PathN1qlError(`Unexpected member expression type '${eType}'.`); break; } case 'subscript': { if (eType !== 'string_literal') throw new ottoman_errors_1.PathN1qlError(`Unexpected subscript expression type '${eType}'.`); break; } default: throw new ottoman_errors_1.PathN1qlError(`Unexpected path operation type '${operation}'.`); } fields.push(`\`${eValue}\``); } return fields.join('.'); }; exports.pathToN1QL = pathToN1QL; //# sourceMappingURL=path-to-n1ql.js.map