JsonFilter

Enum JsonFilter 

Source
pub enum JsonFilter {
Show 14 variants Equals(JsonPath, Value), NotEquals(JsonPath, Value), Contains(String, Value), ContainedBy(String, Value), HasAnyKey(String, Vec<String>), HasAllKeys(String, Vec<String>), HasKey(String, String), GreaterThan(JsonPath, Value), LessThan(JsonPath, Value), Exists(JsonPath), IsNull(JsonPath), IsNotNull(JsonPath), ArrayContains(JsonPath, Value), PathMatch(String, String),
}
Expand description

A JSON filter operation.

Variants§

§

Equals(JsonPath, Value)

Check if path equals a value.

§

NotEquals(JsonPath, Value)

Check if path does not equal a value.

§

Contains(String, Value)

Check if JSON contains another JSON value (PostgreSQL @>).

§

ContainedBy(String, Value)

Check if JSON is contained by another JSON value (PostgreSQL <@).

§

HasAnyKey(String, Vec<String>)

Check if any of the keys exist (PostgreSQL ?|).

§

HasAllKeys(String, Vec<String>)

Check if all of the keys exist (PostgreSQL ?&).

§

HasKey(String, String)

Check if a key exists (PostgreSQL ?).

§

GreaterThan(JsonPath, Value)

Check if path value is greater than.

§

LessThan(JsonPath, Value)

Check if path value is less than.

§

Exists(JsonPath)

Check if path exists.

§

IsNull(JsonPath)

Check if path is null.

§

IsNotNull(JsonPath)

Check if path is not null.

§

ArrayContains(JsonPath, Value)

Check if array contains value.

§

PathMatch(String, String)

Check value using JSONPath predicate (PostgreSQL @?).

Implementations§

Source§

impl JsonFilter

Source

pub fn equals(path: JsonPath, value: impl Into<JsonValue>) -> Self

Create an equals filter.

Source

pub fn contains(column: impl Into<String>, value: impl Into<JsonValue>) -> Self

Create a contains filter.

Source

pub fn has_key(column: impl Into<String>, key: impl Into<String>) -> Self

Create a has key filter.

Source

pub fn exists(path: JsonPath) -> Self

Create an exists filter.

Source

pub fn to_postgres_sql(&self) -> (String, Vec<FilterValue>)

Generate PostgreSQL SQL for this filter.

Source

pub fn to_mysql_sql(&self) -> (String, Vec<FilterValue>)

Generate MySQL SQL for this filter.

Source

pub fn to_sql( &self, db_type: DatabaseType, ) -> QueryResult<(String, Vec<FilterValue>)>

Generate SQL for the specified database.

Trait Implementations§

Source§

impl Clone for JsonFilter

Source§

fn clone(&self) -> JsonFilter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsonFilter

Source§

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

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

impl<'de> Deserialize<'de> for JsonFilter

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for JsonFilter

Source§

fn eq(&self, other: &JsonFilter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for JsonFilter

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JsonFilter

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,