DELETE

DELETE

DELETE immediately removes the specified document from your keyspace.

delete:

DELETE FROM keyspace-ref [use-keys-clause] [where-clause] 
    [limit-clause] [returning-clause]    

keyspace-ref:

[ (namespace-name :)] keyspace-name

use-keys-clause:

USE [PRIMARY] KEYS expression

where-clause:

WHERE condition

limit-clause:

LIMIT expression

returning-clause:

RETURNING (result-expression [, result-expression]* | [RAW | ELEMENT ] expression)

keyspace-ref:Specifies the data source from which to delete the document. You can add an optional namespace name to the keyspace name in this way:

namespace-name:keyspace-name 

For example, main:customer indicates the customer keyspace in the main namespace. If the namespace name is omitted, the default namespace in the current session is used.

use-keys-clause:Specifies the keys of the data items to be deleted. Optional. Keys can be any expression.

where-clause:Specifies the condition that needs to be met for data to be deleted. Optional.

limit-clause:Specifies the greatest number of objects that can be deleted. This clause must have a non-negative integer as its upper bound. Optional.

returning-clause:Returns the data you deleted as specified in the result_expression. Optional.

Examples:

The following statement deletes product10.

DELETE FROM product p USE KEYS "product10" RETURNING p

"results": [
    {
        "p": {
            "categories": [
                "Luggage"
            ],
            "color": "sky blue",
            "dateAdded": "2014-05-06T15:52:18Z",
            "dateModified": "2014-05-06T15:52:18Z",
            "description": "This product is available on 
                \u003ca target=\"_blank\" 
                href=\"http://www.amazon.com/gp/product/
                B005HNKFSM/ref=s9_hps_bw_g198_ir011?pf_rd_m=ATVPDKIKX0DER\
                u0026pf_rd_s=merchandised-search-5\u0026pf_
                rd_r=D182EDFE2F434403B401\u0026pf_rd_t=101\
                u0026pf_rd_p=1486061902\u0026pf_rd_i=15743161
                \"\u003eAmazon.com\u003c/a\u003e.",
            "imageURL": "http://ecx.images-amazon.com/
                images/I/51KiHy-Y-2L._SY220_.jpg",
            "name": "Briggs \
                u0026 Riley Luggage Executive Clamshell Backpack",
            "productId": "product10",
            "reviewList": [
                "review47",
                "review873",
                "review1224",
                "review2203",
                "review2242",
                "review6162",
                "review6825",
                "review7300",
                "review9934"
            ],
            "type": "product",
            "unitPrice": 231.2
        }
    }
]

The following statement deletes the product that is priced at 5.25.


DELETE FROM product p WHERE p.unitPrice = 5.25 RETURNING p.productId

"results": [
        {
            "productId": "product99"
        }
    ]