pub struct Field<M, T> { /* private fields */ }Expand description
Typed column handle for model M whose Rust type is T.
Generated as associated constants by the Model derive:
impl User { pub const name: Field<User, String> = Field::new("name"); }.
Implementations§
Source§impl<M, T> Field<M, T>
impl<M, T> Field<M, T>
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Create a field handle. Intended for generated code.
Sourcepub fn outer_ref(self) -> Expr
pub fn outer_ref(self) -> Expr
Reference to this column of the enclosing query, for use inside a
correlated subquery (Django OuterRef).
Sourcepub fn set(self, value: impl Operand<M, T>) -> (Ident, Expr)
pub fn set(self, value: impl Operand<M, T>) -> (Ident, Expr)
column = value assignment for QuerySet::update.
Sourcepub fn set_expr(self, value: impl Into<Expr>) -> (Ident, Expr)
pub fn set_expr(self, value: impl Into<Expr>) -> (Ident, Expr)
column = <expression> assignment, e.g. Post::likes.set_expr(Post::likes + 1).
Sourcepub fn select(self) -> SelectExpr
pub fn select(self) -> SelectExpr
Project this column in values(..), named after the column.
Source§impl<M, T> Field<M, T>
impl<M, T> Field<M, T>
Sourcepub fn is_not_null(self) -> Expr
pub fn is_not_null(self) -> Expr
IS NOT NULL.
Sourcepub fn is_in<L: Literal<T>>(self, values: impl IntoIterator<Item = L>) -> Expr
pub fn is_in<L: Literal<T>>(self, values: impl IntoIterator<Item = L>) -> Expr
Membership in a list of literals.
Sourcepub fn in_subquery(self, plan: QueryPlan) -> Expr
pub fn in_subquery(self, plan: QueryPlan) -> Expr
Membership in the single column a subquery selects.
Source§impl<M, T: TextLike> Field<M, T>
impl<M, T: TextLike> Field<M, T>
Sourcepub fn starts_with(self, needle: impl Into<String>) -> Expr
pub fn starts_with(self, needle: impl Into<String>) -> Expr
Text lookup starts_with.
Sourcepub fn istarts_with(self, needle: impl Into<String>) -> Expr
pub fn istarts_with(self, needle: impl Into<String>) -> Expr
Text lookup istarts_with.
Sourcepub fn iends_with(self, needle: impl Into<String>) -> Expr
pub fn iends_with(self, needle: impl Into<String>) -> Expr
Text lookup iends_with.
Trait Implementations§
impl<M, T> Copy for Field<M, T>
Source§impl<M, T> From<Field<M, T>> for SelectExpr
impl<M, T> From<Field<M, T>> for SelectExpr
Auto Trait Implementations§
impl<M, T> Freeze for Field<M, T>
impl<M, T> RefUnwindSafe for Field<M, T>
impl<M, T> Send for Field<M, T>
impl<M, T> Sync for Field<M, T>
impl<M, T> Unpin for Field<M, T>
impl<M, T> UnsafeUnpin for Field<M, T>
impl<M, T> UnwindSafe for Field<M, T>
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