0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby: CouchDB のデータを削除 (Delete)

Posted at
couch_delete.rb
#! /usr/bin/ruby
# -*- encoding: utf-8 -*-
#
#	couch_delete.rb
#
#					Jul/31/2020
#
# ---------------------------------------------------------------------
require 'faraday'
require 'json'
#
# ---------------------------------------------------------------------
STDERR.puts	"*** 開始 ***"
#
key_in = ARGV[0]
puts key_in

URL="http://localhost:5984/nagano/" + key_in
#
res = Faraday.get URL

puts	res.status

if res.status == 200 then
	json_str = res.body

	data_aa=JSON.parse(json_str)
#
	puts data_aa
	puts data_aa["_rev"]
#
	url_del = URL + "?rev=" + data_aa["_rev"]

	res = Faraday.delete url_del

	puts res.status
end

STDERR.puts	"*** 終了 ***"
# ---------------------------------------------------------------------

実行

./couch_delete.rb t2026
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?