-
Notifications
You must be signed in to change notification settings - Fork 2
3.3) Update
Guido Barbaglia edited this page May 27, 2015
·
6 revisions
The service can be consumed through a PUT
call to WDS and it is possible to update multiple rows/documents at once.
This parameter is used to specify the name of the collection, for MongoDB and OrientDB databases, or the name of the table, for SQL databases. New resources will be created in the specified collection/table.
The payload contains the query that selects the documents/rows to be updated and the object that represents the new document/row values.
{
"query": {
"state": "MA"
},
"update": {
"state": "CA",
"cities": [
"San Diego",
"San Francisco"
]
}
}
In addition to the aforementioned parameters it is possible to specify two more options:
Name | Description | Default |
---|---|---|
upsert | If no documents match the query, a new document is created in the collection. | false |
multi | The update is applied to all the documents matching the query. | false |
{
"query": {
"state": "MA"
},
"update": {
"state": "CA",
"cities": [
"San Diego",
"San Francisco"
]
},
"upsert": true,
"multi": true
}
$.ajax({
type: 'PUT',
url: 'rest/crud',
data: {
payload: {
"query": {
"state": "MA"
},
"update": {
"state": "CA",
"cities": [
"San Diego",
"San Francisco"
]
},
"upsert": true,
"multi": true
},
datasource: "my_datasource",
collection: "my_collection",
outputType: "object"
},
success: function (response) {
/* Do something with the output... */
},
error: function (a) {
alert(a.responseText)
}
});