Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

[API] DELETE

padewitte edited this page Dec 4, 2014 · 8 revisions

DELETE rest/{database}/{collection}

Delete items in a collection.

Request parameters

Parameter Type Mandatory Comment

{database}

url

yes

database name

{collection}

url

yes

collection name

body

body

no

Querie identifing document to delete

query

header

yes if no body provided

Querie identifing document to delete

writeConcern

header

no

Write concern to use.

Result

Parameter Type Mandatory Comment

body

body

yes

MongoDB getLastError content.

RecordsAffected

header

yes

Number of documents deleted

Examples

Succesfuly delete quering by field name
curl  -XDELETE -H "query:{'name' : 'Thomas'}" \
   http://localhost:8080/kupra/test/col
{
  "serverUsed" : "/127.0.0.1:27017" ,
  "n" : 1 ,
  "connectionId" : 2 ,
  "err" : null ,
  "ok" : 1.0
}
Delete all document with a certain field
curl  -XDELETE -H "query:{'toBeDeleted' : {\$exists : true}}" \
   http://localhost:8080/kupra/test/col
{
  "serverUsed" : "/127.0.0.1:27017" ,
  "n" : 1 ,
  "connectionId" : 2 ,
  "err" : null ,
  "ok" : 1.0
}