Closed dotWee closed 9 years ago
I'm actually not sure how to use SQLite functions with Squidb. For example, if I want to use the date function: SELECT WHERE (property) IS date('now')
(¹), which methods should I use and how to implement it into a query?
Have you seen this wiki page? It outlines most of the basic use cases for functions.
SquiDB doesn't build in a wrapper for every SQLite function, but for the ones it doesn't you can use Function.functionWithArguments as I suggested above. Criterions generally work with arbitrary objects, including Functions. So in addition to doing Model.MY_PROPERTY.eq(1)
you can do Model.MY_PROPERTY.eq(someFunction)
, e.g.:
Function dateFunction = Function.functionWithArguments("date", "now", otherArgs);
Query query = Query.select()
.from(Model.TABLE)
.where(Model.MY_PROPERTY.is(dateFunction));
Does that help?
That helped me a lot! Thanks!
Can you give some more details about your function? If it's a function that takes some arguments, you can simply use
Function.functionWithArguments("functionName", arg1, arg2, ...)
. Or did you have something else in mind?