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
貼文的流式查詢構建器。
透過 PostArchiverManager::posts() 取得。
§可用過濾欄位
ids:依PostId陸列過濾。title:依標題進行LIKE模糊匹配。source:依來源字串進行LIKE模糊匹配。updated:依最後更新時間進行範圍過濾。published:依發布時間進行範圍過濾。platforms:依所屬平台的PlatformId陸列過濾。tags:展性匹配標籤,最小定包含透過post_tags關聯表指定的所有TagId。authors:展性匹配作者,結構同上,透過author_posts關聯表。collections:展性匹配收藏集,結構同上,透過collection_posts關聯表。
§範例
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>§collections: RelationshipsFilter<CollectionId>Implementations§
Source§impl<'a, C: PostArchiverConnection> PostQuery<'a, C>
impl<'a, C: PostArchiverConnection> PostQuery<'a, C>
pub fn new(manager: &'a PostArchiverManager<C>) -> Self
Trait Implementations§
Source§impl<C: PostArchiverConnection> BaseFilter for PostQuery<'_, C>
impl<C: PostArchiverConnection> BaseFilter for PostQuery<'_, C>
type Based = Post
Source§fn update_sql<T: FromQuery<Based = Self::Based>>(
&self,
sql: RawSql<T>,
) -> RawSql<T>
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>
fn queryer(&self) -> &Queryer<'_, impl PostArchiverConnection>
Return a reference to the
Queryer owned by this builder, used by the default count() impl.fn count(&self) -> Result<u64>
Source§impl<C: PostArchiverConnection> Query for PostQuery<'_, C>
impl<C: PostArchiverConnection> Query for PostQuery<'_, C>
Source§type Wrapper<U> = Vec<U>
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§impl<C> Sortable for PostQuery<'_, C>
impl<C> Sortable for PostQuery<'_, C>
Source§type SortField = PostSort
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>
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>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Countable for Twhere
T: Query,
impl<T> Countable for Twhere
T: Query,
Source§fn with_total(self) -> WithTotal<Self>
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> Paginate for Twhere
T: Query,
impl<T> Paginate for Twhere
T: Query,
Source§fn pagination(self, limit: u64, page: u64) -> Paginated<T>
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.