Skip to content

Instantly share code, notes, and snippets.

@xiaoyvr
Created July 26, 2017 15:25
Show Gist options
  • Save xiaoyvr/32612303088458389333e7722bf3bdda to your computer and use it in GitHub Desktop.
Save xiaoyvr/32612303088458389333e7722bf3bdda to your computer and use it in GitHub Desktop.
how couchbase sync gateway generate the document revision id
func createRevID(generation int, parentRevID string, body Body) string {
// This should produce the same results as TouchDB.
digester := md5.New()
digester.Write([]byte{byte(len(parentRevID))})
digester.Write([]byte(parentRevID))
digester.Write(canonicalEncoding(stripSpecialProperties(body)))
return fmt.Sprintf("%d-%x", generation, digester.Sum(nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment