Skip to main content

PostQuery

Struct PostQuery 

Source
pub struct PostQuery<'a, C> {
    pub ids: IdFilter<PostId>,
    pub title: TextFilter,
    pub source: TextFilter,
    pub updated: DateFilter,
    pub published: DateFilter,
    pub platforms: IdFilter<PlatformId>,
    pub tags: RelationshipsFilter<TagId>,
    pub authors: RelationshipsFilter<AuthorId>,
    pub collections: RelationshipsFilter<CollectionId>,
    /* private fields */
}
Available on crate feature utils only.
Expand description

Fluent query builder for posts. Obtained via PostArchiverManager::posts().

§Available filter fields

  • ids: filter by a set of PostId values.
  • title: fuzzy match on the title.
  • source: fuzzy match on the post source.
  • updated:filter by last-updated timestamp range.
  • published:filter by published timestamp range.
  • platforms:filter by a set of PlatformId values.
  • tags:filter by a set of TagId values, through the post_tags relation table.
  • authors:filter by a set of AuthorId values, through the author_posts relation table。
  • collections:filter by a set of CollectionId values, through the collection_posts relation table.

§Example

let posts = manager.posts()
    .sort(PostSort::Updated, SortDir::Desc)
    .pagination(20, 0)
    .query::<post_archiver::Post>()
    .unwrap();

Fields§

§ids: IdFilter<PostId>§title: TextFilter§source: TextFilter§updated: DateFilter§published: DateFilter§platforms: IdFilter<PlatformId>§tags: RelationshipsFilter<TagId>§authors: RelationshipsFilter<AuthorId>§collections: RelationshipsFilter<CollectionId>

Implementations§

Source§

impl<'a, C: PostArchiverConnection> PostQuery<'a, C>

Source

pub fn new(manager: &'a PostArchiverManager<C>) -> Self

Trait Implementations§

Source§

impl<C: PostArchiverConnection> BaseFilter for PostQuery<'_, C>

Source§

type Based = Post

Source§

fn update_sql<T: FromQuery<Based = Self::Based>>( &self, sql: RawSql<T>, ) -> RawSql<T>

Append all filter conditions held by this builder into sql and return the updated RawSql.
Source§

fn queryer(&self) -> &Queryer<'_, impl PostArchiverConnection>

Return a reference to the Queryer owned by this builder, used by the default count() impl.
Source§

fn count(&self) -> Result<u64>

Source§

impl<'a, C: Debug> Debug for PostQuery<'a, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: PostArchiverConnection> Query for PostQuery<'_, C>

Source§

type Wrapper<U> = Vec<U>

The wrapper type for query results. For most builders this is Vec<T>; when wrapped by WithTotal it becomes Totalled<Vec<T>>.
Source§

type Based = Post

The database table type this query targets.
Source§

fn query_with_context<T: FromQuery<Based = Self::Based>>( self, sql: RawSql<T>, ) -> Result<Self::Wrapper<T>>

Execute the query with an externally supplied RawSql context (typically threaded through decorator layers).
Source§

fn query<T: FromQuery<Based = Self::Based>>(self) -> Result<Self::Wrapper<T>>

Execute the query with a default empty RawSql context, returning all matching results.
Source§

impl<C> Sortable for PostQuery<'_, C>

Source§

type SortField = PostSort

The sortable field enum type, defined in each sub-module by impl_sortable!.
Source§

fn sort( self, field: Self::SortField, dir: SortDir, ) -> Sorted<Self, Self::SortField>

Sort by the given field and direction, returning Sorted<Self, SortField>.
Source§

fn sort_random(self) -> Sorted<Self, Random>

Sort results randomly using ORDER BY RANDOM().

Auto Trait Implementations§

§

impl<'a, C> Freeze for PostQuery<'a, C>

§

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

§

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

§

impl<'a, C> Sync for PostQuery<'a, C>
where C: Sync,

§

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

§

impl<'a, C> UnsafeUnpin for PostQuery<'a, C>

§

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

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Countable for T
where T: Query,

Source§

fn with_total(self) -> WithTotal<Self>

Available on crate feature utils only.
Wrap this builder in WithTotal<Self>. When Query::query() is called, an additional COUNT(*) query is executed and the result is placed in the total field of the returned Totalled.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Paginate for T
where T: Query,

Source§

fn pagination(self, limit: u64, page: u64) -> Paginated<T>

Available on crate feature utils only.
Wrap this builder with limit (items per page) and page (0-based page index), returning Paginated<Self> which appends LIMIT limit OFFSET limit*page on execution.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.