[][src]Struct arangors::collection::Collection

pub struct Collection<'a, C: ClientExt> { /* fields omitted */ }

A collection consists of documents. It is uniquely identified by its collection identifier. It also has a unique name that clients should use to identify and access it. Collections can be renamed. This will change the collection name, but not the collection identifier. Collections have a type that is specified by the user when the collection is created. There are currently two types: document and edge. The default type is document.

Implementations

impl<'a, C: ClientExt> Collection<'a, C>[src]

pub fn collection_type(&self) -> &CollectionType[src]

pub fn id(&self) -> &str[src]

pub fn name(&self) -> &str[src]

pub fn url(&self) -> &Url[src]

pub fn session(&self) -> Arc<C>[src]

pub async fn drop(self) -> Result<String, ClientError>[src]

Drops a collection

pub async fn truncate<'_>(&'_ self) -> Result<Info, ClientError>[src]

Truncate current collection.

pub async fn properties<'_>(&'_ self) -> Result<Properties, ClientError>[src]

Fetch the properties of collection

pub async fn document_count<'_>(&'_ self) -> Result<Properties, ClientError>[src]

Counts the documents in this collection

pub async fn statistics<'_>(&'_ self) -> Result<Statistics, ClientError>[src]

Fetch the statistics of a collection

the result also contains the number of documents and additional statistical information about the collection. Note: This will always load the collection into memory.

Note: collection data that are stored in the write-ahead log only are not reported in the results. When the write-ahead log is collected, documents might be added to journals and datafiles of the collection, which may modify the figures of the collection.

Additionally, the filesizes of collection and index parameter JSON files are not reported. These files should normally have a size of a few bytes each. Please also note that the fileSize values are reported in bytes and reflect the logical file sizes. Some filesystems may use optimisations (e.g. sparse files) so that the actual physical file size is somewhat different. Directories and sub-directories may also require space in the file system, but this space is not reported in the fileSize results.

That means that the figures reported do not reflect the actual disk usage of the collection with 100% accuracy. The actual disk usage of a collection is normally slightly higher than the sum of the reported fileSize values. Still the sum of the fileSize values can still be used as a lower bound approximation of the disk usage.

pub async fn revision_id<'_>(&'_ self) -> Result<Revision, ClientError>[src]

Retrieve the collections revision id

The revision id is a server-generated string that clients can use to check whether data in a collection has changed since the last revision check.

pub async fn checksum<'_>(&'_ self) -> Result<Checksum, ClientError>[src]

Fetch a checksum for the specified collection

Will calculate a checksum of the meta-data (keys and optionally revision ids) and optionally the document data in the collection. The checksum can be used to compare if two collections on different ArangoDB instances contain the same contents. The current revision of the collection is returned too so one can make sure the checksums are calculated for the same state of data.

By default, the checksum will only be calculated on the _key system attribute of the documents contained in the collection. For edge collections, the system attributes _from and _to will also be included in the calculation.

By setting the optional query parameter withRevisions to true, then revision ids (_rev system attributes) are included in the checksumming.

By providing the optional query parameter withData with a value of true, the user-defined document attributes will be included in the calculation too. Note: Including user-defined attributes will make the checksumming slower. this function would make a request to arango server.

pub async fn checksum_with_options<'_>(
    &'_ self,
    options: ChecksumOptions
) -> Result<Checksum, ClientError>
[src]

Fetch a checksum for the specified collection

Will calculate a checksum of the meta-data (keys and optionally revision ids) and optionally the document data in the collection. The checksum can be used to compare if two collections on different ArangoDB instances contain the same contents. The current revision of the collection is returned too so one can make sure the checksums are calculated for the same state of data.

By default, the checksum will only be calculated on the _key system attribute of the documents contained in the collection. For edge collections, the system attributes _from and _to will also be included in the calculation.

By setting the optional query parameter withRevisions to true, then revision ids (_rev system attributes) are included in the checksumming.

By providing the optional query parameter withData with a value of true, the user-defined document attributes will be included in the calculation too. Note: Including user-defined attributes will make the checksumming slower. this function would make a request to arango server.

pub async fn load<'_>(&'_ self, count: bool) -> Result<Info, ClientError>[src]

Loads a collection into memory. Returns the collection on success.

The request body object might optionally contain the following attribute:

  • count: If set, this controls whether the return value should include the number of documents in the collection. Setting count to false may speed up loading a collection. The default value for count is true.

pub async fn unload<'_>(&'_ self) -> Result<Info, ClientError>[src]

Removes a collection from memory. This call does not delete any documents. You can use the collection afterwards; in which case it will be loaded into memory, again.

pub async fn load_indexes<'_>(&'_ self) -> Result<bool, ClientError>[src]

Load Indexes into Memory

This route tries to cache all index entries of this collection into the main memory. Therefore it iterates over all indexes of the collection and stores the indexed values, not the entire document data, in memory. All lookups that could be found in the cache are much faster than lookups not stored in the cache so you get a nice performance boost. It is also guaranteed that the cache is consistent with the stored data.

For the time being this function is only useful on RocksDB storage engine, as in MMFiles engine all indexes are in memory anyways.

On RocksDB this function honors all memory limits, if the indexes you want to load are smaller than your memory limit this function guarantees that most index values are cached. If the index is larger than your memory limit this function will fill up values up to this limit and for the time being there is no way to control which indexes of the collection should have priority over others.

On success this function returns an object with attribute result set to true

pub async fn change_properties<'_>(
    &'_ self,
    properties: PropertiesOptions
) -> Result<Properties, ClientError>
[src]

Changes the properties of a collection.

pub async fn rename<'_, '_>(
    &'_ mut self,
    name: &'_ str
) -> Result<Info, ClientError>
[src]

Renames the collection

pub async fn recalculate_count<'_>(&'_ self) -> Result<bool, ClientError>[src]

Recalculates the document count of a collection Note: this method is specific for the RocksDB storage engine

pub async fn create_document<T, '_>(
    &'_ self,
    doc: T,
    insert_options: InsertOptions
) -> Result<DocumentResponse<T>, ClientError> where
    T: Serialize + DeserializeOwned
[src]

Creates a new document from the document given in the body, unless there is already a document with the _key given. If no _key is given, a new unique _key is generated automatically. Possibly given _id and _rev attributes in the body are always ignored, the URL part or the query parameter collection respectively counts.

If the document was created successfully, then the Location header contains the path to the newly created document. The Etag header field contains the revision of the document. Both are only set in the single document case.

If silent is not set to true, the body of the response contains a JSON object with the following attributes:

_id contains the document identifier of the newly created document _key contains the document key _rev contains the document revision If the collection parameter waitForSync is false, then the call returns as soon as the document has been accepted. It will not wait until the documents have been synced to disk.

Optionally, the query parameter waitForSync can be used to force synchronization of the document creation operation to disk even in case that the waitForSync flag had been disabled for the entire collection. Thus, the waitForSync query parameter can be used to force synchronization of just this specific operations. To use this, set the waitForSync parameter to true. If the waitForSync parameter is not specified or set to false, then the collection’s default waitForSync behavior is applied. The waitForSync query parameter cannot be used to disable synchronization for collections that have a default waitForSync value of true.

If the query parameter returnNew is true, then, for each generated document, the complete new document is returned under the new attribute in the result.

pub async fn document<T, '_, '_>(
    &'_ self,
    _key: &'_ str
) -> Result<Document<T>, ClientError> where
    T: Serialize + DeserializeOwned
[src]

Reads a single document Returns the document identified by document-id. The returned document contains three special attributes: _id containing the document identifier, _key containing key which uniquely identifies a document in a given collection and _rev containing the revision.

pub async fn read_document_with_options<T, '_, '_>(
    &'_ self,
    _key: &'_ str,
    read_options: ReadOptions
) -> Result<Document<T>, ClientError> where
    T: Serialize + DeserializeOwned
[src]

pub async fn document_header<'_, '_>(
    &'_ self,
    _key: &'_ str
) -> Result<Header, ClientError>
[src]

Reads a single document header Like GET, but only returns the header fields and not the body. You can use this call to get the current revision of a document or check if the document was deleted.

pub async fn document_header_with_options<'_, '_>(
    &'_ self,
    _key: &'_ str,
    read_options: ReadOptions
) -> Result<Header, ClientError>
[src]

pub async fn update_document<T, '_, '_>(
    &'_ self,
    _key: &'_ str,
    doc: T,
    update_options: UpdateOptions
) -> Result<DocumentResponse<T>, ClientError> where
    T: Serialize + DeserializeOwned
[src]

Partially updates the document

pub async fn replace_document<T, '_, '_>(
    &'_ self,
    _key: &'_ str,
    doc: T,
    replace_options: ReplaceOptions,
    if_match_header: Option<String>
) -> Result<DocumentResponse<T>, ClientError> where
    T: Serialize + DeserializeOwned
[src]

Replaces the document Replaces the specified document with the one in the body, provided there is such a document and no precondition is violated.

The value of the _key attribute as well as attributes used as sharding keys may not be changed.

If the If-Match header is specified and the revision of the document in the database is unequal to the given revision, the precondition is violated. If If-Match is not given and ignoreRevs is false and there is a _rev attribute in the body and its value does not match the revision of the document in the database, the precondition is violated. If a precondition is violated, an HTTP 412 is returned. If the document exists and can be updated, then an HTTP 201 or an HTTP 202 is returned (depending on waitForSync, see below), the Etag header field contains the new revision of the document and the Location header contains a complete URL under which the document can be queried. Cluster only: The replace documents may contain values for the collection’s pre-defined shard keys. Values for the shard keys are treated as hints to improve performance. Should the shard keys values be incorrect ArangoDB may answer with a not found error. Optionally, the query parameter waitForSync can be used to force synchronization of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection. Thus, the waitForSync query parameter can be used to force synchronization of just specific operations. To use this, set the waitForSync parameter to true. If the waitForSync parameter is not specified or set to false, then the collection’s default waitForSync behavior is applied. The waitForSync query parameter cannot be used to disable synchronization for collections that have a default waitForSync value of true. If silent is not set to true, the body of the response contains a JSON object with the information about the identifier and the revision. The attribute _id contains the known document-id of the updated document, _key contains the key which uniquely identifies a document in a given collection, and the attribute _rev contains the new document revision. If the query parameter returnOld is true, then the complete previous revision of the document is returned under the old attribute in the result. If the query parameter returnNew is true, then the complete new document is returned under the new attribute in the result. If the document does not exist, then a HTTP 404 is returned and the body of the response contains an error document. You can conditionally replace a document based on a target revision id by using the if-match HTTP header.

pub async fn remove_document<T, '_, '_>(
    &'_ self,
    _key: &'_ str,
    remove_options: RemoveOptions,
    if_match_header: Option<String>
) -> Result<DocumentResponse<T>, ClientError> where
    T: Serialize + DeserializeOwned
[src]

Removes a document If silent is not set to true, the body of the response contains a JSON object with the information about the identifier and the revision. The attribute _id contains the known document-id of the removed document, _key contains the key which uniquely identifies a document in a given collection, and the attribute _rev contains the document revision. You can conditionally replace a document based on a target revision id by using the if-match HTTP header.

Trait Implementations

impl<'a, C: Clone + ClientExt> Clone for Collection<'a, C>[src]

impl<'a, C: Debug + ClientExt> Debug for Collection<'a, C>[src]

Auto Trait Implementations

impl<'a, C> RefUnwindSafe for Collection<'a, C> where
    C: RefUnwindSafe

impl<'a, C> Send for Collection<'a, C> where
    C: Send

impl<'a, C> Sync for Collection<'a, C> where
    C: Send

impl<'a, C> Unpin for Collection<'a, C>

impl<'a, C> UnwindSafe for Collection<'a, C> where
    C: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.