-
Notifications
You must be signed in to change notification settings - Fork 14
Bulk Document Processing
debasishg edited this page Sep 13, 2010
·
1 revision
Documents can be manipulated in bulks. Through one single POST, new documents can be simultaneously added, existing ones updated and deleted. Here is a sample session ..
// should insert 2 new documents, update 1 existing document and delete 1
// a scala object
val s = Shop("Shoppers Stop", "refrigerator", 12500)
val d = Doc(test, "ss")
// another scala object
val t = Address("Monroe Street", "Denver, CO", "987651")
val ad = Doc(test, "add1")
var ir:(String, String) = null
var ir1:(String, String) = null
// create a new document
http(d add s)
ir = http(d ># %(Id._id, Id._rev))
ir._1 should equal("ss")
// create another new document
http(ad add t)
ir1 = http(ad ># %(Id._id, Id._rev))
ir1._1 should equal("add1")
// new scala objects
val s1 = Shop("cc", "refrigerator", 12500)
val s2 = Shop("best buy", "macpro", 1500)
val a1 = Address("Survey Park", "Kolkata", "700075")
// a dsl that adds s1 and s2, updates s and deletes t
val d1 = bulkBuilder(Some(s1)).id("a").build
val d2 = bulkBuilder(Some(s2)).id("b").build
val d3 = bulkBuilder(Some(s)).id("ss").rev(ir._2).build
val d4 = bulkBuilder(None).id("add1").rev(ir1._2).deleted(true).build
http(test bulkDocs(List(d1, d2, d3, d4), false)).size should equal(4)