UNPKG

@datastax/astra-mongoose

Version:

Astra's NodeJS Mongoose compatibility client

42 lines 1.91 kB
"use strict"; // Copyright DataStax, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = convertSchemaToUDTColumns; const convertSchemaToColumns_1 = __importDefault(require("../convertSchemaToColumns")); const astraMongooseError_1 = require("../astraMongooseError"); /** * Given a Mongoose schema, create an equivalent Data API table definition for use with `createTable()` */ function convertSchemaToUDTColumns(schema, udtName) { const schemaColumns = (0, convertSchemaToColumns_1.default)(schema, udtName); const columns = {}; for (const [name, column] of Object.entries(schemaColumns)) { // Inline disallowed types so TypeScript can correctly check types if (typeof column === 'object' && (column?.type === 'map' || column?.type === 'list' || column?.type === 'set' || column?.type === 'vector' || column?.type === 'userDefined')) { throw new astraMongooseError_1.AstraMongooseError(`${column.type} is not supported for UDT columns`); } columns[name] = column; } return columns; } //# sourceMappingURL=convertSchemaToUDTColumns.js.map