LoginSignup
0
0

More than 1 year has passed since last update.

CouchDB をさわってみたメモ

Posted at

作成:2023年4月11日
CouchDB を触ってみたくなったので、触ったメモを残します。

Docker で CouchDB を導入とテスト

Docker で CouchDB を立てて、DB やデータの追加を色々試してみます。

console
# 起動
% docker run -it -p 5984:5984 --name my-couchdb -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password apache/couchdb:3.3.1

# 試しにDB追加
% curl -X PUT http://admin:password@127.0.0.1:5984/_users
{"ok":true}
% curl -X PUT http://admin:password@127.0.0.1:5984/_replicator
{"ok":true}
% curl -X PUT http://admin:password@127.0.0.1:5984/_global_changes
{"ok":true}
% curl -X GET http://admin:password@127.0.0.1:5984/_all_dbs       
["_global_changes","_replicator","_users"]

# 試しにデータ追加してデータ確認
% curl -X PUT http://admin:password@127.0.0.1:5984/test_db
{"ok":true}
% curl -X PUT http://admin:password@127.0.0.1:5984/test_db/test_doc -d '{"name":"hoge"}'
{"ok":true,"id":"test_doc","rev":"1-8efae2575443e0b3ff301aee512fc284"}
% curl http://admin:password@127.0.0.1:5984/test_db/test_doc
{"_id":"test_doc","_rev":"1-8efae2575443e0b3ff301aee512fc284","name":"hoge"}
% curl -X GET http://admin:password@127.0.0.1:5984/_all_dbs
["_global_changes","_replicator","_users","test_db"]

# 試しにDB削除
% curl -X DELETE http://admin:password@127.0.0.1:5984/_replicator
{"ok":true}
% curl -X GET http://admin:password@127.0.0.1:5984/_all_dbs        
["_global_changes","_users","test_db"]

参考

公式Github
  CouchDB Docker image の使い方
2.1. Single Node Setup
公式Tutorial
CouchDBの構築 on Ubuntu
  Docker で CouchDB 導入の記事
Golang で CouchDB のデータを作成 (Create)

検索

CouchDB のきほんチートシート curl 編
  view を使った絞り込み検索
Cloudant(CouchDB) の MapReduce ビュー
1.1. API Basics
1.3.6. /db/_find

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