本文介绍了CouchDB如何计算修订号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图了解CouchDB如何计算文档的修订ID。我从源头注意到,它是通过以下这段代码计算的:I'm trying to understand how CouchDB calculates the revision id for a document. I notice from the source that it's calculated by this bit of code here:couch_util:md5(term_to_binary([Deleted, OldStart, OldRev, Body, Atts2]))我知道,如果我创建一个没有附件中,CouchDB始终对其进行修订-1-967a00dff5e02add41819138abb3284d,十进制为>。And I know that if I create a new empty document with no attachments, CouchDB always gives it a revision of 1-967a00dff5e02add41819138abb3284d which, in decimal is <<150,122,0,223,245,224,42,221,65,129,145,56,171,179,40,77>>.但是,如果我在erlang提示符下输入以下内容(对于false,则为false;对于OldStart,0为OldRev,为空正文,没有附件):However, if I type the following into the erlang prompt (false for deleted, 0 for OldStart, 0 for OldRev, an empty body and no attachments):erlang:md5(term_to_binary([false, 0, 0, [], []])).我总是得到<<26,196,244,40,211,149,193,185,214,6,230,61,54,138,62,132>>回来。那我是什么推荐答案在阅读从CouchDB中的Erlang视图中发出元组我意识到我做错的不是包装元组中空的属性列表。我不知道为什么沙发会这样做,但这就是问题所在。After reading the answer to Emit Tuples From Erlang Views In CouchDB I realised that what I was doing wrong was not wrapping the empty proplist for body in a tuple. I'm not sure why couch does that, but that's what the problem was.erlang:md5(term_to_binary([false, 0, 0, {[]}, []])).给出正确的答案< < 150,122,0,223,245,224,42,221,65,129,145,56,171,179,40,77 >><<150,122,0,223,245,224,42,221,65,129,145,56,171,179,40,77>> 这篇关于CouchDB如何计算修订号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 01:50