update document

francisco treacy francisco.treacy at gmail.com
Mon Nov 2 11:58:10 EST 2009


I am developing a Scala library for Riak while I learn more about this
datastore.

I have covered storing/fetching documents, so far so good. But when I
try to 'update' a document I am noticing a behaviour I didn't expect:
As an example, when I execute this Ruby code:

client = JiakClient.new('localhost', 8098)
b = {'key' => "key", 'bucket' => "test", :links => [], 'object' => {
:my => "json2" }}
c = {'key' => "key", 'bucket' => "test", :links => [], 'object' => {
:my => "json3" }}
client.store b
client.store c
r = client.fetch 'test', 'key'
puts r['object']['my']

the output is always "json2", where I would normally expect "json3".

However, immediately after I do:
curl -X PUT http://localhost:8098/jiak/test/key -H "Content-Type:
application/json" --data "{\"bucket\":\"test\", \"key\":\"key\",
\"object\":{\"my\":\"json4\"}, \"links\":[]}"
curl http://localhost:8098/test/key

...and the result is "json4", which seems fine. (If I execute the Ruby
code again, I get "json2").

So I guess my question is... what is going on here?  Why doesn't it
store the object with "json3"?
Looks like it can't cope with subsequent updates, but is that tied to
the fact of having vclocks or something to do with the N/R/W values?

Thanks,

Francisco




More information about the riak-users mailing list