Reputation: 109
can someone tell me please is there a way to pass custom parameters on getting table (or insert, update...) from azure mobile services. My scripts sometimes are using request.parameters but I didn't find any example of adding them in Android SDK.
Is there a way?
Upvotes: 0
Views: 835
Reputation: 87218
For each of the [insert | update | delete] methods there is an overload which allow you to pass those parameters - the overload with a List<Pair<String, String>>
argument. This is how you'd pass a few extra parameters in an insert call:
MobileServiceTable<TodoItem> table = mClient.getTable(TodoItem.class);
List<Pair<String, String>> queryParams = new ArrayList<Pair<String, String>>();
queryParams.add(new Pair<String, String>("option", "value"));
table.insert(todoItem, queryParams, new TableOperationCallback<TodoItem>() {
public void onCompleted(TodoItem inserted, Exception error, ServiceFilterResponse response) {
// Your logic here
}
});
For delete / update, the code is similar.
For query operations, you can pass the parameters via the parameter
method:
MobileServiceTable<TodoItem> table = mClient.getTable(TodoItem.class);
table
.where().field("complete").eq(val(false))
.parameter("option", "value")
.parameter("otherOption", "otherValue")
.execute(new TableQueryCallback<TodoItem>() {
public void onCompleted(List<TodoItem> results, int count, Exception error, ServiceFilterResponse response) {
// Your logic here
}
});
Upvotes: 1