Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
jeaye edited this page Jun 5, 2018 · 3 revisions

delete

NOTE: Each of these queries presented here may be incomplete and may be lacking the final rendering call: to_string.

The casst delete API begins with only one entrypoint.

casst::delete_  // DELETE

The variadic entrypoint function expects a list of lvalue column names. From there, whe need to say whence we're deleting.

from

This expects a single table name.

casst::delete_("col1", "col2", "col3").
  from("turb")

// DELETE col1, col2, col3 FROM turb

After this, you have several choices.

where

casst::delete_("col1", "col2", "col3").from("turb").
  where(casst::equal("name", "meow"))

// DELETE col1, col2, col3 FROM turb WHERE name = 'meow'

if_

casst::delete_().from("people").
  where(casst::row("meow").in("kitty", "cat")).
  if_
  (
    casst::equal("name", "meow"),
    casst::and_(),
    casst::equal("alive", false)
  )

// DELETE FROM people WHERE meow IN ( 'kitty', 'cat' )
// IF name = 'meow' AND alive = false

if_exists

casst::delete_().from("turb").if_exists()

// DELETE FROM turb IF EXISTS

using_timestamp

Very similar to update's using, except this doesn't allow for TTL, so timestamp become part of the function name.

casst::delete_().from("people").using_timestamp(476500).
  where(casst::equal("alive", false))

// DELETE FROM people USING TIMESTAMP 476500 WHERE alive = false

Clone this wiki locally