[−][src]Struct arangors::collection::Collection
Represent a collection in Arango server that consists of documents/edges.
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]
The collection identifier
A collection identifier lets you refer to a collection in a database. It is a string value and is unique within the database. Up to including ArangoDB 1.1, the collection identifier has been a client’s primary means to access collections. Starting with ArangoDB 1.2, clients should instead use a collection’s unique name to access a collection instead of its identifier. ArangoDB currently uses 64bit unsigned integer values to maintain collection ids internally. When returning collection ids to clients, ArangoDB will put them into a string to ensure the collection id is not clipped by clients that do not support big integers. Clients should treat the collection ids returned by ArangoDB as opaque strings when they store or use them locally.
pub fn name(&self) -> &str
[src]
The collection name
A collection name identifies a collection in a database. It is a string and is unique within the database. Unlike the collection identifier it is supplied by the creator of the collection. The collection name must consist of letters, digits, and the _ (underscore) and - (dash) characters only. Please refer to Naming Conventions in ArangoDB for more information on valid collection names.
pub fn url(&self) -> &Url
[src]
Collection url: http://server:port/_db/mydb/_api/collection/{collection-name}
This url is used to work on the collection itself
pub fn doc_url(&self) -> &Url
[src]
Document base url: http://server:port/_db/mydb/_api/document/{collection-name}
This url is used to work with documents
pub fn session(&self) -> Arc<C>
[src]
HTTP Client used to query the server
pub async fn drop(self) -> Result<String, ClientError>
[src]
pub async fn truncate<'_>(&'_ self) -> Result<Info, ClientError>
[src]
pub async fn properties<'_>(&'_ self) -> Result<Properties, ClientError>
[src]
pub async fn document_count<'_>(&'_ self) -> Result<Properties, ClientError>
[src]
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 file sizes 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.
Note
this function would make a request to arango server.
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.
Note
this function would make a request to arango server.
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.
Note
this function would make a request to arango server.
pub async fn checksum_with_options<'_>(
&'_ self,
options: ChecksumOptions
) -> Result<Checksum, ClientError>
[src]
&'_ self,
options: ChecksumOptions
) -> Result<Checksum, ClientError>
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.
Note
this function would make a request to arango server.
pub async fn load<'_>(&'_ self, count: bool) -> Result<Info, ClientError>
[src]
Load 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.
Note
this function would make a request to arango server.
pub async fn unload<'_>(&'_ self) -> Result<Info, ClientError>
[src]
Remove 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.
Note
this function would make a request to arango server.
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
Note
this function would make a request to arango server.
pub async fn change_properties<'_>(
&'_ self,
properties: PropertiesOptions
) -> Result<Properties, ClientError>
[src]
&'_ self,
properties: PropertiesOptions
) -> Result<Properties, ClientError>
pub async fn rename<'_, '_>(
&'_ mut self,
name: &'_ str
) -> Result<Info, ClientError>
[src]
&'_ mut self,
name: &'_ str
) -> Result<Info, ClientError>
pub async fn recalculate_count<'_>(&'_ self) -> Result<bool, ClientError>
[src]
Recalculate the document count of a collection
Note: this method is specific for the RocksDB storage engine
Note
this function would make a request to arango server.
pub async fn create_document<T, '_>(
&'_ self,
doc: T,
insert_options: InsertOptions
) -> Result<DocumentResponse<T>, ClientError> where
T: Serialize + DeserializeOwned,
[src]
&'_ self,
doc: T,
insert_options: InsertOptions
) -> Result<DocumentResponse<T>, ClientError> where
T: Serialize + DeserializeOwned,
Create 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.
Note
this function would make a request to arango server.
pub async fn document<T, '_, '_>(
&'_ self,
_key: &'_ str
) -> Result<Document<T>, ClientError> where
T: Serialize + DeserializeOwned,
[src]
&'_ self,
_key: &'_ str
) -> Result<Document<T>, ClientError> where
T: Serialize + DeserializeOwned,
Read a single document with _key
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.
Note
this function would make a request to arango server.
pub async fn document_with_options<T, '_, '_>(
&'_ self,
_key: &'_ str,
read_options: ReadOptions
) -> Result<Document<T>, ClientError> where
T: Serialize + DeserializeOwned,
[src]
&'_ self,
_key: &'_ str,
read_options: ReadOptions
) -> Result<Document<T>, ClientError> where
T: Serialize + DeserializeOwned,
Read a single document with options
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.
Note
this function would make a request to arango server.
pub async fn document_header<'_, '_>(
&'_ self,
_key: &'_ str
) -> Result<Header, ClientError>
[src]
&'_ self,
_key: &'_ str
) -> Result<Header, ClientError>
Read 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.
Note
this function would make a request to arango server.
pub async fn document_header_with_options<'_, '_>(
&'_ self,
_key: &'_ str,
read_options: ReadOptions
) -> Result<Header, ClientError>
[src]
&'_ self,
_key: &'_ str,
read_options: ReadOptions
) -> Result<Header, ClientError>
Read a single document header with options
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.
Note
this function would make a request to arango server.
pub async fn update_document<T, '_, '_>(
&'_ self,
_key: &'_ str,
doc: T,
update_options: UpdateOptions
) -> Result<DocumentResponse<T>, ClientError> where
T: Serialize + DeserializeOwned,
[src]
&'_ self,
_key: &'_ str,
doc: T,
update_options: UpdateOptions
) -> Result<DocumentResponse<T>, ClientError> where
T: Serialize + DeserializeOwned,
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]
&'_ self,
_key: &'_ str,
doc: T,
replace_options: ReplaceOptions,
if_match_header: Option<String>
) -> Result<DocumentResponse<T>, ClientError> where
T: Serialize + DeserializeOwned,
Replace a 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.
Note
this function would make a request to arango server.
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]
&'_ self,
_key: &'_ str,
remove_options: RemoveOptions,
if_match_header: Option<String>
) -> Result<DocumentResponse<T>, ClientError> where
T: Serialize + DeserializeOwned,
Remove 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.
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 returnOld is true, then the complete previous revision of the document is returned under the old attribute in the result.
You can conditionally replace a document based on a target revision id by using the if-match HTTP header.
Note
this function would make a request to arango server.
Trait Implementations
impl<'a, C: Clone + ClientExt> Clone for Collection<'a, C>
[src]
fn clone(&self) -> Collection<'a, C>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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,
C: RefUnwindSafe,
impl<'a, C> Send for Collection<'a, C> where
C: Send,
C: Send,
impl<'a, C> Sync for Collection<'a, C> where
C: Send,
C: Send,
impl<'a, C> Unpin for Collection<'a, C>
impl<'a, C> UnwindSafe for Collection<'a, C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,