xref: /6.0.3/couchstore/csdata.md (revision 2bf88351)
1## Couchstore Data Types
2
3Struct members not listed should be considered internal to Couchstore.
4
5### sized_buf
6    struct sized_buf {
7        char* buf;
8        size_t size;
9    }
10
11Couchstore uses `sized_buf`s to point to data buffers. 
12
13### DocInfo
14    struct DocInfo {
15        sized_buf id;
16        uint64_t db_seq;
17        uint64_t rev_seq;
18        sized_buf rev_meta;
19        int deleted;
20        uint8_t content_meta;
21    }
22
23* `id` - Document ID
24* `db_seq` - Change sequence number the document was inserted at.
25* `rev_seq` - The version number of the document
26* `rev_meta` - Revision metadata. Used by ep-engine to store CAS value, expiry time, and flags
27* `deleted` - 1 if document should be considered "deleted" and not subject to indexing, otherwise 0.
28* `content_meta` - Number field used to store flags indicating metadata about the document content (is it JSON, etc.)
29
30When saving documents with `save_doc` or `save_docs`, `id`, `rev_seq`, `rev_meta`, `deleted`, and `content_meta` must be set on the `DocInfo`s passed to Couchstore. The `db_seq` is determined at insert time.
31
32
33### Doc
34    struct Doc {
35        sized_buf id;
36        sized_buf data;
37    }
38
39`id` contains the document ID, `data` contains the document body data. Couchstore does not compress or modify the body data in any way.
40
41### LocalDoc
42    struct LocalDoc {
43        sized_buf id;
44        sized_buf json;
45        int deleted;
46    }
47
48* `id`  - The local document ID, it must start with `_local/`
49* `json` - The local document body.
50* `deleted` - if set to 1 on a LocalDoc passed to save_local_doc, `json` will be ignored, and the local document with the ID in `id` will be removed, if it exists.
51
52
53## C API
54
55Documented in `include/libcouchstore/couch_db.h`
56
57
58