Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

575 B
Raw Blame
import type { MongodbAuthValue } from './types';

function databaseName({ auth, database }: { auth: MongodbAuthValue; database?: string }): string {
  const name = database || auth.props.database;
  if (!name) {
    throw new Error('Database is required. Please specify it in the connection settings or in this action.');
  }
  return name;
}

function limit({ value }: { value?: number }): number {
  return Math.min(Math.max(value ?? DEFAULT_LIMIT, 1), MAX_LIMIT);
}

export const mongodbUtils = { databaseName, limit };

const DEFAULT_LIMIT = 100;
const MAX_LIMIT = 1000;