If you've ever worked with Azure Cosmos DB directly, you know the pain. Writing raw SQL queries by hand, managing parameterized inputs, zero validation before data hits the database. Compare these two approaches for finding electronics under $100:
Raw @azure/cosmos SDK:
const { resources } = await container . items . query ({ query : ' SELECT * FROM c WHERE c.category = @cat AND c.price >= @min AND c.price <= @max ' , parameters : [ { name : ' @cat ' , value : ' electronics ' }, { name : ' @min ' , value : 10 }, { name : ' @max ' , value : 100 }, ], }) . fetchAll ();
Enter fullscreen mode
Exit fullscreen mode
With Cosmoose:
const products = await Product . find ({ category : ' electronics ' , price : { $gte : 10 , $lte : 100 }, });
Enter fullscreen mode
Exit fullscreen mode
Cosmoose is a type-safe ODM for Azure Cosmos DB, built with TypeScript.β¦