{"id":3265,"date":"2016-03-07T02:04:50","date_gmt":"2016-03-07T02:04:50","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3265"},"modified":"2016-03-07T02:04:50","modified_gmt":"2016-03-07T02:04:50","slug":"rethinkdb-delete-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/rethinkdb-delete-example\/","title":{"rendered":"RethinkDB: DELETE example"},"content":{"rendered":"<p>In RethinkDB, you can delete the rows returned by any query:<\/p>\n<pre lang=\"javascript\">r.db('test')\n .table('users')\n  .filter( (doc) =&gt; doc('user_name').match(\"ieling$\") )\n  .delete()\n<\/pre>\n<p>This is a nice change from SQL, where you sometimes have to make much more structural modifications to a query to do a deletion.<\/p>\n<div id=\"sticky-wrap\">\n<div id=\"main-container\">\n<div id=\"cluster\" class=\"container\">\n<div id=\"dataexplorer\">\n<div class=\"section\">\n<div class=\"results_container\">\n<div class=\"result_view\">\n<div class=\"results_header\">\n<p class=\"metadata  feed_paused\">1 row returned in 47ms.<\/p>\n<\/div>\n<div class=\"tab-content\">\n<div class=\"results table_view_container\">\n<div class=\"results_wrap table_view\">\n<div class=\"json_table_container\">\n<table class=\"json_table\">\n<tbody>\n<tr class=\"jta_tr\">\n<td class=\"td_attr col-record col-record-attr\" data-col=\"record\"><\/td>\n<td class=\"td_attr col-0\" data-col=\"0\">\n<div class=\"click_detector\">\n<div class=\"jta_attr value-0\">deleted<\/div>\n<\/div>\n<\/td>\n<td class=\"td_attr col-1\" data-col=\"1\">\n<div class=\"click_detector\">\n<div class=\"jta_attr value-1\">errors<\/div>\n<\/div>\n<\/td>\n<td class=\"td_attr col-2\" data-col=\"2\">\n<div class=\"click_detector\">\n<div class=\"jta_attr value-2\">inserted<\/div>\n<\/div>\n<\/td>\n<td class=\"td_attr col-3\" data-col=\"3\">\n<div class=\"click_detector\">\n<div class=\"jta_attr value-3\">replaced<\/div>\n<\/div>\n<\/td>\n<td class=\"td_attr col-4\" data-col=\"4\">\n<div class=\"click_detector\">\n<div class=\"jta_attr value-4\">skipped<\/div>\n<\/div>\n<\/td>\n<td class=\"td_attr col-5\" data-col=\"5\">\n<div class=\"click_detector\">\n<div class=\"jta_attr value-5\">unchanged<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr class=\"jta_tr\">\n<td class=\"col-record-td\" data-col=\"record\">\n<div class=\"jta_value col-record\">1<\/div>\n<\/td>\n<td class=\"col-0\" data-col=\"0\">\n<div class=\"click_detector\">\n<div class=\"jta_value value-0 jta_num\">1<\/div>\n<\/div>\n<\/td>\n<td class=\"col-1\" data-col=\"1\">\n<div class=\"click_detector\">\n<div class=\"jta_value value-1 jta_num\">0<\/div>\n<\/div>\n<\/td>\n<td class=\"col-2\" data-col=\"2\">\n<div class=\"click_detector\">\n<div class=\"jta_value value-2 jta_num\">0<\/div>\n<\/div>\n<\/td>\n<td class=\"col-3\" data-col=\"3\">\n<div class=\"click_detector\">\n<div class=\"jta_value value-3 jta_num\">0<\/div>\n<\/div>\n<\/td>\n<td class=\"col-4\" data-col=\"4\">\n<div class=\"click_detector\">\n<div class=\"jta_value value-4 jta_num\">0<\/div>\n<\/div>\n<\/td>\n<td class=\"col-5\" data-col=\"5\">\n<div class=\"click_detector\">\n<div class=\"jta_value value-5 jta_num\">0<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"footer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In RethinkDB, you can delete the rows returned by any query: r.db(&#8216;test&#8217;) .table(&#8216;users&#8217;) .filter( (doc) =&gt; doc(&#8216;user_name&#8217;).match(&#8220;ieling$&#8221;) ) .delete() This is a nice change from SQL, where you sometimes have to make much more structural modifications to a query to do a deletion. 1 row returned in 47ms. deleted errors inserted replaced skipped unchanged 1 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/rethinkdb-delete-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;RethinkDB: DELETE example&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[160,302,462,523],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3265"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3265"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3265\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}