Replies: 3 comments
-
Comments? @tyt2y3 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I second the idea of having an ergonimc way to However I think The API can probably look like: let change_set = ChangeSet::new(Cake).set(cake::Column::Counter, cake::Column::Counter.add(1));
change_set.insert(&db).await?; // lets pretend the expression is a function call
change_set
.which(2) // this is the PK, basically where PK = val
.where(SimpleExpr)
.update(&db).await?; // if `which` or `where` is never called, we should refuse to execute |
Beta Was this translation helpful? Give feedback.
0 replies
-
What about something like ... ? ActiveValue::SetExpr(Expr::current_timestamp()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Motivation
It'd be convenient if we allow inserting and updating with expression such as summation of two columns
"num1" + "num2"
or even DB built in functionCURRENT_TIMESTAMP
orUUID()
.Proposed Solutions
Introduce a
SimpleExpr
version ofActiveValue
andActiveModel
. Which conversion methods will be provided to convertActiveValue
intoActiveExpr
andActiveModel
intoActiveExprModel
.Beta Was this translation helpful? Give feedback.
All reactions