module CouchDB::DocumentHelper

Overview

Utility module for low-level document operations.

Prefer instance methods on Document for new code (doc.next_rev, doc.rev_num, doc.deleted?). This module is provided for callers that work with documents generically and may also be used by adapter internals.

Defined in:

couchdb/document.cr

Class Method Summary

Class Method Detail

def self.deleted?(doc : Document) : Bool #

Returns true when the document's deleted field is true.


[View source]
def self.next_rev(doc : Document) : String #

Computes the next revision for doc using the CouchDB "N-<md5>" scheme.

The hash is derived from the document JSON with _rev removed so that the revision string is deterministic given the same document content.


[View source]
def self.rev_num(rev : String) : Int32 #

Parses the generation number from a revision string (e.g. "3-abc"3). Returns 0 for malformed input.


[View source]