agdb 0.12.10

Agnesoft Graph Database
Documentation
use crate::QueryIds;
use crate::RemoveValuesQuery;
use crate::SearchQuery;
use crate::query_builder::search::Search;

/// Remove values builder that lets you select the ids from
/// which to remove the values.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct RemoveValues(pub RemoveValuesQuery);

/// Final builder that lets you create
/// an actual query object.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct RemoveValuesIds(pub RemoveValuesQuery);

#[cfg_attr(feature = "api", agdb::impl_def())]
impl RemoveValues {
    /// Id, list of ids or search of the database elements to delete
    /// the values from. All of the ids must exist in the database.
    pub fn ids<T: Into<QueryIds>>(mut self, ids: T) -> RemoveValuesIds {
        self.0.0.ids = ids.into();

        RemoveValuesIds(self.0)
    }

    /// Remove the values from the elements found using the search query.
    /// Equivalent to `ids(QueryIds::Search(search)/*...*/)`.
    pub fn search(mut self) -> Search<RemoveValuesQuery> {
        self.0.0.ids = QueryIds::Search(SearchQuery::new());
        Search(self.0)
    }
}

#[cfg_attr(feature = "api", agdb::impl_def())]
impl RemoveValuesIds {
    /// Returns the built `RemoveValuesQuery` object.
    pub fn query(self) -> RemoveValuesQuery {
        self.0
    }
}