webCOMAND

Delete Web Service

Remove one or more objects from the repository. The desired object(s) are specified using an optional query. If query is not specified, an error is returned.

Request

  • query: <OID> | "<UUID>" | "<cPath>" | "<cQL>" | [] – Optional OID, UUID, cPath or cQL query or array of queries used to determine the object(s) to delete. cQL can be a SELECT query.
  • revision: "active" | <ID> | "<timestamp>" – The revision ID or timestamp to find the closest revision that will be used with the query to determine the object versions to remove. If revision is not specified or 'active' is specified, the latest/active version will be removed.
  • prune: <N> | "<timestamp>" | "<time>" – Optional parameter to specify which past versions of an object should be deleted.  If a number is specified, that number of latest versions will be retained and all older versions deleted. If a timestamp is provided, all versions older than the specified timestamp will be deleted.  If a time is provided, all versions older than the specified time will be deleted, where time is interpreted by strtotime().
  • session: "<session ID>" – Optional parameter to specify the user session. If it is not specified, the cookie will be checked for the session.
  • token: "<token>" – Optional parameter to specify the User Token. If it is not specified, the cookie will be checked for the token.

Response

The response includes the following properties, in addition to the Common Response Properties.

  • deleted: <N> – Number of top-level objects deleted, excluding embedded/referenced objects.
  • embeddedDeleted: <N> – Number of objects deleted, including embedded/referenced objects.
  • objects: [{}, {}, ...] – Array of objects that represent each deleted top-level object, each with an OID, UUID and Type field and value. The Type field value is an object with an OID, UUID and Identifier.
  • embeddedObjects: [{}, {}, ...] – Array of objects that represent each deleted embedded object, each with an OID, UUID and Type field and value. The Type field value is an object with an OID, UUID and Identifier.

Example

// delete objects by OID
$.ajax({
	url: 'https://<account>.webcomand.com/ws/delete',
	data: {
		query: 'DELETE WHERE OID IN (22,23,24)'
	},
	success: function(data){
		if(data.status === true) {
			alert(data.deleted " objects deleted.");
		} else {
			alert("Error deleting objects: " + data.status);
		}
	}
});

// prune image versions older than 1 year
$.ajax({
	url: 'https://<account>.webcomand.com/ws/delete',
	data: {
		query: 'FROM Image' }
		prune: '-1 year' }
	},
	success: function(data){
		if(data.status === true) {
			alert(data.deleted " objects versions deleted.");
		} else {
			alert("Error deleting objects: " + data.status);
		}
	}
});