There is a tutorial on Casbah:
http://api.mongodb.org/scala/casbah/current/tutorial.html
But it's hard for me to follow the tutorial as I am still learning Scala.
All I wanted to learn was how to perform simple CRUD operations using Casbah, to get started with before I can move on.
The following are domain models:
class Hotel (var name: String, var stars: Int, val address: Address) class Address(var street:String, var city: String, var postCode: String) val address = new Address(street = "1234 st", city = "edmond", postCode = "1232234", country = "USA" ) val hotel = new Hotel(name = "Super Nice", stars = 4, address = address) val address2 = new Address(street = "main st", city = "edmond", postCode = "1232234", country = "USA" ) val hotel2 = new Hotel(name = "Big Hotel", stars = 4, address = address2)
Given which Kasbakh code should perform these tasks?
(1) save as hotels in mongodb
(2) find all hotels with stars equal to 4 or greater than 4. This should give me a list over which I can repeat
(3) find a hotel called “Super Nice” and change its name to “Ultra Nice”
(4) get the addresses of all hotels and change the country to lower case and save in the database
source share