Limitations
Current limitations of CosmosQL and planned features
CosmosQL focuses on core CRUD operations and common query patterns that cover the majority of application use cases. This document outlines what's currently supported, what's missing, and workarounds for common scenarios.
Current Version Status
Production Ready: ✅ Yes - Core operations are stable and well-tested
Test Coverage: Comprehensive test suite covering all core functionality
Architecture:
- Zero dependencies - Only TypeScript required
- Type-level programming - Schema inference and type safety
- REST API direct - No SDK wrapper, minimal overhead
- Bun runtime - Optimized for Bun 1.0+ and Node.js 18+
Missing Features
1. Advanced Pagination
CosmosQL currently only supports offset-based pagination using take and skip. Cursor-based pagination and continuation tokens are not yet supported.
Current Support:
// Offset pagination (LIMIT/OFFSET)
const page1 = await db.posts.findMany({
partitionKey: 'user_123',
take: 20,
skip: 0
});
const page2 = await db.posts.findMany({
partitionKey: 'user_123',
take: 20,
skip: 20
});Limitations:
- No cursor-based pagination
- No continuation token support
- Cross-partition queries with large offsets can be expensive
Workaround: For large datasets, consider:
- Partition-scoped queries - Stay within partitions to minimize costs
- Date/time-based filtering - Use timestamp filters instead of large offsets
- Manual continuation tokens - Use raw SQL queries with continuation tokens (advanced)
Future Plans: Cursor-based pagination and continuation token support are planned.
2. Transaction Support
CosmosQL does not support:
- Multi-document transactions
- Batch operations beyond
createMany(which requires same partition key) - Transaction rollback capabilities
- Cross-partition transactions
Current Support:
// Single-partition batch operations only
await db.posts.createMany({
data: [
{ id: 'post_1', userId: 'user_123', title: 'Post 1' },
{ id: 'post_2', userId: 'user_123', title: 'Post 2' }
],
partitionKey: 'user_123' // All documents must share partition key
});Limitations:
- Cannot atomically update multiple documents across partitions
- No rollback support
- Limited to operations within a single partition
Workaround: For multi-document operations:
- Design for single-partition operations - Structure data so related documents share partition keys
- Use application-level transactions - Implement compensating actions for failures
- Use Azure SDK for transactions - For complex scenarios, use the official SDK alongside CosmosQL
Future Plans: Transaction support is under consideration for future releases.
3. Cross-Partition Query Limitations
Azure CosmosDB Restriction: Cross-partition queries are limited on empty containers. This is a CosmosDB limitation, not a CosmosQL limitation.
When attempting cross-partition queries on empty containers, CosmosDB returns an error. This is by design to prevent expensive operations on empty data.
Workaround: Ensure containers have at least one document before running cross-partition queries, or use partition-scoped queries when possible.
4. Advanced Query Features
The following CosmosDB features are not yet supported:
- Geospatial queries - Spatial indexing is supported in schema definition but full geospatial queries require raw SQL
- Full-text search - Integration with Azure Cognitive Search (not supported via REST API)
- JOIN operations - Not applicable to document databases, but no support for array joins
- Stored procedures - Cannot execute stored procedures (REST API focus)
- User-defined functions (UDFs) - Cannot use UDFs in queries (REST API focus)
Workaround: Use raw SQL queries for features not supported by the query builder:
// Geospatial example (when supported via raw SQL)
const result = await db.locations.query({
sql: `
SELECT * FROM c
WHERE ST_DISTANCE(c.location, {
'type': 'Point',
'coordinates': [@lng, @lat]
}) < @distance
`,
parameters: [
{ name: '@lng', value: -122.4194 },
{ name: '@lat', value: 37.7749 },
{ name: '@distance', value: 5000 }
]
});Future Plans: Advanced query features may be added based on community demand.
5. Performance Optimizations
Missing performance-related features:
- Query result caching - No built-in caching layer
- Query plan analysis - No automatic query optimization suggestions
- Automatic indexing suggestions - No recommendations for index optimization
- Connection pool management - Basic pooling exists, but limited configuration
Workaround:
- Implement caching at application level - Use Redis or in-memory caching for frequently accessed data
- Monitor RU usage - Track Request Unit consumption in Azure Portal
- Optimize partition keys - Ensure good partition key selection (documented in Performance Guide)
- Use point reads - Prefer
findUniqueoverfindManywhen querying single documents
Future Plans: Performance monitoring and optimization tools may be added.
6. Change Feed
CosmosQL does not support:
- Change feed processors
- Real-time change notifications
- Document change tracking
Workaround: Use the official Azure SDK for change feed processing:
// Using Azure SDK for change feed
import { CosmosClient } from '@azure/cosmos';
const client = new CosmosClient(connectionString);
const container = client.database('mydb').container('users');
// Use SDK for change feed
const changeFeedProcessor = container.items
.changeFeed({
startFromBeginning: false
})
.on('change', (changes) => {
// Handle changes
});Future Plans: Change feed support is being considered for future releases.
7. Multi-Database Operations
CosmosQL works with a single database per client instance. Cross-database operations are not supported.
Workaround: Create multiple client instances:
const productionDb = await createClient({
connectionString: process.env.COSMOS_CONNECTION_STRING!,
database: 'production',
mode: 'verify'
}).withContainers({ users, posts });
const analyticsDb = await createClient({
connectionString: process.env.COSMOS_CONNECTION_STRING!,
database: 'analytics',
mode: 'verify'
}).withContainers({ events, metrics });Feature Comparison
| Feature | CosmosQL | Azure SDK | Status |
|---|---|---|---|
| Type Safety | ✅ Full | ❌ Limited | CosmosQL advantage |
| CRUD Operations | ✅ Complete | ✅ Complete | Equivalent |
| Aggregations | ✅ Type-safe | ✅ Native | Equivalent |
| Transactions | ⚠️ Single partition | ✅ Full support | SDK advantage |
| Change Feed | ❌ Not supported | ✅ Supported | SDK advantage |
| Database Management | ✅ Full management | ✅ Full management | Equivalent |
| Zero Dependencies | ✅ Yes | ❌ 50+ packages | CosmosQL advantage |
| Query Builder | ✅ Type-safe | ❌ SQL strings | CosmosQL advantage |
When to Use CosmosQL vs Azure SDK
Use CosmosQL when:
- ✅ You prioritize type safety and developer experience
- ✅ You need zero dependencies for serverless/microservices
- ✅ Your use cases fit core CRUD operations
- ✅ You want compile-time guarantees for partition keys
- ✅ You're building new TypeScript applications
- ✅ You need database and container management (with
auto-create,verify, orskipmodes)
Use Azure SDK when:
- ✅ You need advanced features (change feed, stored procedures)
- ✅ You need cross-partition transactions
- ✅ You're working with JavaScript (not TypeScript)
- ✅ You need geospatial queries or full-text search
Use Both:
You can use CosmosQL alongside the Azure SDK for different use cases within the same project. They don't interfere with each other and work with the same database.
Roadmap
High Priority:
- ✅ Core CRUD operations (Completed)
- ✅ Type-safe query builder (Completed)
- ✅ Aggregation functions (Completed)
- 🔄 Cursor pagination (Planned)
- 🔄 Batch operations (Planned)
Medium Priority:
- ✅ Container management APIs (Completed)
- ⏳ Advanced querying (Geospatial, full-text) (Future)
- ⏳ Performance monitoring (Future)
- ⏳ Migration support (Future)
Lower Priority:
- ⏳ Multiple database support (Future)
- ⏳ Advanced connection pooling (Future)
- ⏳ Circuit breaker patterns (Future)
Reporting Issues
If you encounter limitations that impact your use case:
- Check existing issues on GitHub
- Create a feature request with use case details
- Contribute - Pull requests welcome!
- Use workarounds - Many limitations have documented workarounds
Getting Help
For questions about limitations or missing features:
- Check the FAQ for common questions
- Review Patterns & Use Cases for workarounds
- Open a GitHub issue for specific feature requests
- Join the community Discord for discussions