@azure/cosmos (TypeScript/JavaScript)
Build Cosmos DB applications with TypeScript
Developers need to perform CRUD operations on Azure Cosmos DB documents efficiently. This skill provides TypeScript patterns for queries, bulk operations, and proper authentication.
Descargar el ZIP de la skill
Subir en Claude
Ve a Configuración → Capacidades → Skills → Subir skill
Activa y empieza a usar
Pruébalo
Usando "@azure/cosmos (TypeScript/JavaScript)". Create a product document with name 'Laptop', price 999.99, category 'electronics'
Resultado esperado:
Successfully created document with id 'prod-8a7b2c' in container 'products'. Request charge: 5.21 RUs.
Usando "@azure/cosmos (TypeScript/JavaScript)". Query products where price < 1000 and category = 'electronics'
Resultado esperado:
Retrieved 15 products matching criteria. Total request charge: 3.47 RUs. Results include: Laptop, Tablet, Wireless Mouse, USB Hub...
Auditoría de seguridad
SeguroPrompt-only instructional skill containing documentation for Azure Cosmos DB SDK usage. Static analysis scanned 0 files with 0 findings and risk score 0/100. No executable code, network access, or security concerns detected. The skill teaches proper security practices including AAD authentication and parameterized queries.
Puntuación de calidad
Lo que puedes crear
Backend developer building a SaaS application
Implement a multi-tenant data layer using hierarchical partition keys to isolate customer data while maintaining query performance.
Data engineer processing high-volume transactions
Use bulk operations to efficiently insert, update, and delete thousands of documents per second with proper error handling.
Full-stack developer creating real-time applications
Build change feed processors and implement optimistic concurrency to handle concurrent updates from multiple clients.
Prueba estos prompts
Create a TypeScript function that inserts a new product document into Azure Cosmos DB. The product should have id, name, price, and category fields. Use DefaultAzureCredential for authentication and include proper error handling for duplicate documents.
Write a TypeScript service method that queries Cosmos DB for products within a price range. Use SqlQuerySpec with named parameters to prevent injection attacks. Include pagination support with continuation tokens.
Implement a bulk import function that processes an array of 1000+ documents using executeBulkOperations. Handle partial failures by logging failed operations with their status codes while continuing successful ones.
Create an update function that uses ETags to prevent lost updates when multiple users modify the same document. Return a specific error when the ETag precondition fails so the client can refresh and retry.
Mejores prácticas
- Use DefaultAzureCredential for authentication instead of account keys in production environments
- Always use parameterized queries with SqlQuerySpec to prevent injection and improve query plan caching
- Specify partition key values in all point operations to avoid cross-partition query overhead
Evitar
- Using account keys directly in code instead of environment variables or managed identity
- Executing SELECT * queries without WHERE clauses on large containers
- Ignoring 429 rate limit errors instead of implementing exponential backoff retry logic