Struct sofa::Document [−][src]
pub struct Document { pub _id: DocumentId, pub _rev: String, // some fields omitted }
Document abstracts the handling of JSON values and provides direct access and casting to the fields of your documents
You can get access to the fields via the implementation of the Index
and IndexMut
traits
Fields
_id: DocumentId
Document ID, provided by CouchDB
_rev: String
Document Revision, provided by CouchDB, helps negotiating conflicts
Methods
impl Document
[src]
impl Document
pub fn new(doc: Value) -> Document
[src]
pub fn new(doc: Value) -> Document
pub fn get_keys(&self) -> Vec<String>
[src]
pub fn get_keys(&self) -> Vec<String>
Returns all document's keys
pub fn get_data(&self) -> Value
[src]
pub fn get_data(&self) -> Value
Returns raw JSON data from document
pub fn merge(&mut self, doc: Value) -> &Self
[src]
pub fn merge(&mut self, doc: Value) -> &Self
Merges this document with a raw JSON value, useful to update data with a payload
pub fn populate(&mut self, field: &String, db: Database) -> &Self
[src]
pub fn populate(&mut self, field: &String, db: Database) -> &Self
Recursively populates field (must be an array of IDs from another database) with provided database documents
Trait Implementations
impl PartialEq for Document
[src]
impl PartialEq for Document
fn eq(&self, other: &Document) -> bool
[src]
fn eq(&self, other: &Document) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Document) -> bool
[src]
fn ne(&self, other: &Document) -> bool
This method tests for !=
.
impl Debug for Document
[src]
impl Debug for Document
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Document
[src]
impl Clone for Document
fn clone(&self) -> Document
[src]
fn clone(&self) -> Document
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<I> Index<I> for Document where
I: Index,
[src]
impl<I> Index<I> for Document where
I: Index,
type Output = Value
The returned type after indexing.
fn index(&self, index: I) -> &Value
[src]
fn index(&self, index: I) -> &Value
Performs the indexing (container[index]
) operation.
impl<I> IndexMut<I> for Document where
I: Index,
[src]
impl<I> IndexMut<I> for Document where
I: Index,