Skip to main content
100%

Gist 370577

✓ Published0🌍 Public
Aakollegger
Last edited Apr 18, 2010
Created on Apr 18, 2010

This example demonstrates a Scala program that interacts with MongoDB through the Casbah MongoDB Scala driver, showing how to define a case class `User` with fields like `id`, `name`, and optional `age`, then insert 50 randomly generated users into a collection. It queries users using the `User` shape's `where` clauses (e.g., `User.age is_> 50`), sorts them by age, and deletes users outside a specified age range. The code also shows inserting a raw `Map` directly into a collection and uses for-comprehensions to iterate over query results, highlighting the driver’s Scala-specific query and collection APIs.

AI-generated description

Similar vizzes