pub trait NamedCollection: Collection + Unpin {
    type ByNameView: SerializedView<Key = String>;
    fn load<'name, 'life0, 'async_trait, N: Into<NamedReference<'name>> + Send + Sync, C: Connection>(
        id: N,
        connection: &'life0 C
    ) -> Pin<Box<dyn Future<Output = Result<Option<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>
    where
        Self: SerializedCollection + Sized + 'static,
        'name: 'async_trait,
        N: 'async_trait,
        C: 'async_trait,
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... }
fn entry<'connection, 'name, N: Into<NamedReference<'name>> + Send + Sync, C: Connection>(
        id: N,
        connection: &'connection C
    ) -> Entry<'connection, 'name, C, Self, (), ()>Notable traits for Entry<'a, 'name, Conn, Col, EI, EU>impl<'a, 'name, Conn, Col, EI, EU> Future for Entry<'a, 'name, Conn, Col, EI, EU> where
    Col: NamedCollection + SerializedCollection + 'static,
    Conn: Connection,
    EI: EntryInsert<Col> + 'a,
    EU: EntryUpdate<Col> + 'a,
    'name: 'a, 
type Output = Result<Option<CollectionDocument<Col>>, Error>;

    where
        Self: SerializedCollection + Sized
, { ... }
fn load_document<'name, 'life0, 'async_trait, N: Into<NamedReference<'name>> + Send + Sync, C: Connection>(
        name: N,
        connection: &'life0 C
    ) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait>>
    where
        Self: SerializedCollection + Sized,
        'name: 'async_trait,
        N: 'async_trait,
        C: 'async_trait,
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... } }
Expand description

A collection with a unique name column.

Finding a document by unique name

if let Some(doc) = MyCollection::load("unique name", &db).await? {
    println!(
        "Retrieved revision {} with deserialized contents: {:?}",
        doc.header.revision, doc.contents
    );
}

Load accepts either a string or a u64. This enables building methods that accept either the unique ID or the unique name:

if let Some(doc) = MyCollection::load(42, &db).await? {
    println!(
        "Retrieved revision {} with deserialized contents: {:?}",
        doc.header.revision, doc.contents
    );
}

Executing an insert or update

let upserted = MyCollection::entry("unique name", &db)
    .update_with(|existing: &mut MyCollection| {
        existing.rank += 1;
    })
    .or_insert_with(MyCollection::default)
    .await?
    .unwrap();
println!("Rank: {:?}", upserted.contents.rank);

Associated Types

The name view defined for the collection.

Provided methods

Gets a CollectionDocument with id from connection.

Gets a CollectionDocument with id from connection.

Loads a document from this collection by name, if applicable. Return Ok(None) if unsupported.

Implementors