pub enum JsonOp {
Set {
column: String,
path: String,
value: Value,
},
Insert {
column: String,
path: String,
value: Value,
},
Replace {
column: String,
path: String,
value: Value,
},
Remove {
column: String,
path: String,
},
ArrayAppend {
column: String,
path: String,
value: Value,
},
ArrayPrepend {
column: String,
path: String,
value: Value,
},
Merge {
column: String,
value: Value,
},
Increment {
column: String,
path: String,
amount: f64,
},
}Expand description
JSON mutation operations.
Variants§
Set
Set a value at a path.
Insert
Insert a value at a path (only if not exists).
Replace
Replace a value at a path (only if exists).
Remove
Remove a key/element.
ArrayAppend
Append to an array.
ArrayPrepend
Prepend to an array.
Merge
Merge two JSON objects.
Increment
Increment a numeric value.
Implementations§
Source§impl JsonOp
impl JsonOp
Sourcepub fn set(
column: impl Into<String>,
path: impl Into<String>,
value: impl Into<JsonValue>,
) -> Self
pub fn set( column: impl Into<String>, path: impl Into<String>, value: impl Into<JsonValue>, ) -> Self
Create a set operation.
Sourcepub fn insert(
column: impl Into<String>,
path: impl Into<String>,
value: impl Into<JsonValue>,
) -> Self
pub fn insert( column: impl Into<String>, path: impl Into<String>, value: impl Into<JsonValue>, ) -> Self
Create an insert operation.
Sourcepub fn remove(column: impl Into<String>, path: impl Into<String>) -> Self
pub fn remove(column: impl Into<String>, path: impl Into<String>) -> Self
Create a remove operation.
Sourcepub fn array_append(
column: impl Into<String>,
path: impl Into<String>,
value: impl Into<JsonValue>,
) -> Self
pub fn array_append( column: impl Into<String>, path: impl Into<String>, value: impl Into<JsonValue>, ) -> Self
Create an array append operation.
Sourcepub fn merge(column: impl Into<String>, value: impl Into<JsonValue>) -> Self
pub fn merge(column: impl Into<String>, value: impl Into<JsonValue>) -> Self
Create a merge operation.
Sourcepub fn increment(
column: impl Into<String>,
path: impl Into<String>,
amount: f64,
) -> Self
pub fn increment( column: impl Into<String>, path: impl Into<String>, amount: f64, ) -> Self
Create an increment operation.
Sourcepub fn to_postgres_expr(&self) -> (String, Vec<FilterValue>)
pub fn to_postgres_expr(&self) -> (String, Vec<FilterValue>)
Generate PostgreSQL SQL expression.
Sourcepub fn to_mysql_expr(&self) -> (String, Vec<FilterValue>)
pub fn to_mysql_expr(&self) -> (String, Vec<FilterValue>)
Generate MySQL SQL expression.
Sourcepub fn to_sql(
&self,
db_type: DatabaseType,
) -> QueryResult<(String, Vec<FilterValue>)>
pub fn to_sql( &self, db_type: DatabaseType, ) -> QueryResult<(String, Vec<FilterValue>)>
Generate SQL for the specified database.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JsonOp
impl<'de> Deserialize<'de> for JsonOp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for JsonOp
Auto Trait Implementations§
impl Freeze for JsonOp
impl RefUnwindSafe for JsonOp
impl Send for JsonOp
impl Sync for JsonOp
impl Unpin for JsonOp
impl UnwindSafe for JsonOp
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