db.save() vs. db.update()

Mathias Meyer mathias at basho.com
Wed Jul 6 09:26:03 EDT 2011


it looks you're mixing up metadata objects with actual data objects when calling update. update does a get/put cycle, where it fetches an object, merges its attributes with the ones you hand over to update() and save the result back. Any change you accidentally pass in the meta object from a different part of your code that's fetching the object initially?

Mathias Meyer
Developer Advocate, Basho Technologies

On Mittwoch, 6. Juli 2011 at 00:30, Claus Guttesen wrote:

> Hi.
> When saving a new record using db.update() getting the record using
> curl has alot more info:
> curl "localhost:8098/riak/users/RQC6seqRIKkBNKQt65QMko3W66"
> {"props":{"w":"quorum","r":"quorum","big_vclock":50,"old_vclock":86400,"n_val":3,"postcommit":[],"last_write_wins":false,"small_vclock":10,"allow_mult":false,"young_vclock":20,"rw":"quorum","pw":0,"dw":"quorum","linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"name":"users","chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"basic_quorum":true,"notfound_ok":false,"pr":0,"precommit":[]},"club":"BBIL","mname":"","year":"1967","gender":"male","fname":"Claus","lname":"Guttesen"}%
> When doing a db.save() with the same data I get:
> curl "localhost:8098/riak/users/RQC6seqRIKkBNKQt65QMko3W66"
> {"fname":"Claus","mname":"","lname":"Guttesen","year":"1967","club":"BBIL","gender":"male"}
> If I do a db.save() first and then a db.update() the information is
> also terse. Why is db.update() more verbose?
> I'm using riak-js v. 0.4.0.
> My idea was to add more information in addtion to name, club, year
> born, gender. But when I edit the user and save it the previous data
> gets overwritten. So I changed db.save() to db.update(), saved a new
> user and noticed alot more info.
> -- 
> regards
> Claus
> When lenity and cruelty play for a kingdom,
> the gentler gamester is the soonest winner.
> Shakespeare
> twitter.com/kometen (http://twitter.com/kometen)
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com (mailto:riak-users at lists.basho.com)
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

More information about the riak-users mailing list