在SQL中,我可以执行类型为
的查询init: function (successCallback, errorCallback) {
var taskRegistered = false;
var taskName = "Your Background Task Name";
var background = Windows.ApplicationModel.Background;
var iter = background.BackgroundTaskRegistration.allTasks.first();
// check if service already started
while (iter.hasCurrent) {
var task = iter.current.value;
if (task.name === taskName) {
taskRegistered = true;
break;
}
iter.moveNext();
}
if (taskRegistered) {
successCallback();
} else {
Windows.ApplicationModel.Background.BackgroundExecutionManager.requestAccessAsync().then(function () {
var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder();
builder.name = taskName;
builder.taskEntryPoint = "CordovaApp.Library.UploadTask"; // namespace of my windows runtime component library
builder.setTrigger(new Windows.ApplicationModel.Background.TimeTrigger(15, false));
builder.addCondition(new Windows.ApplicationModel.Background.SystemCondition(Windows.ApplicationModel.Background.SystemConditionType.internetAvailable));
return builder.register();
}).done(function () {
successCallback();
}, function (err) {
errorCallback(err);
});
}
},
给我一份清单:
SELECT cost > 1000 AS above_k, name FROM products;
如何使用+---------+--------+
| above_k | name |
+---------+--------+
| true | Gold |
| false | Silver |
+---------+--------+
为类似查询建模? (显然)我不能这样做:
jooq
因为,没有方法ctx.select(Tables.PRODUCTS.COST.gt(1000))
。或者,如果我只是想:
select(Condition condition)
有没有办法用jooq做到这一点?
答案 0 :(得分:6)
SELECT cost > 1000 AS above_k, name
FROM products;
ctx.select(field(PRODUCTS.COST.gt(1000)).as("above_k"), PRODUCTS.NAME)
.from(PRODUCTS)
.fetch();
SELECT cost*0.9 AS discounted_cost
FROM products;
ctx.select(PRODUCTS.COST.mul(0.9).as("discounted_cost"))
.from(PRODUCTS)
.fetch();