RammusXu / rammusxu.github.io

My profile
https://rammusxu.github.io/
2 stars 0 forks source link

Restheart - Study #37

Closed RammusXu closed 7 years ago

RammusXu commented 8 years ago

來源:https://docs.mongodb.com/ecosystem/tools/http-interfaces/ 選擇:http://restheart.org/

Docker

docker run -v /Users/rammus/docker-workspace/mongodb/data:/data --name mongo -d mongo
 docker run -it --rm \
    --name mongo-express \
    --link mongo:mongo \
    -p 8081:8081 \
    -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" \
    -e ME_CONFIG_BASICAUTH_USERNAME="rammus" \
    -e ME_CONFIG_BASICAUTH_PASSWORD="rammuspwd" \
    mongo-express
 docker run -it --rm \
    --name mongo-express \
    --link mongo:mongo \
    -p 8081:8081 \
    mongo-express

https://github.com/mongo-express/mongo-express

restheart

https://github.com/SoftInstigate/restheart-docker https://softinstigate.atlassian.net/wiki/display/RH/Enable+and+Configure+Security

Reference

RammusXu commented 8 years ago

如果沒有安裝過 docker-compose

sudo pip install docker-compose

下載 docker-compose.yml

# Origin : MongoDB + RestHeart
git clone https://github.com/SoftInstigate/restheart-docker.git

# With mongo-express
git clone https://github.com/RammusXu/restheart-docker.git

Run

# 啟動
cd restheart-docker ; docker-compose up -d 

# 測試
curl -u admin:changeit localhost:8080

Snippets

# 新增 db
curl -u admin:changeit PUT 127.0.0.1:8080/testdb

# 新增 collection
curl -u admin:changeit -XPUT 127.0.0.1:8080/testdb/customers -H "Content-Type: application/json" -d '{"name":"rammus"}'

# 查詢 collection
curl -u admin:changeit -XGET 127.0.0.1:8080/testdb/customers -H "Content-Type: application/json"
# 去除collection properties
curl -u admin:changeit -XGET "127.0.0.1:8080/testdb/customers&np" -H "Content-Type: application/json"
{
    "_id": "customers",
    "name": "Annieeeeeee",
    "age": 36,
    "_etag": {
        "$oid": "57ce4124a7b11b0005529f42"
    },
    "_returned": 15,
    "_embedded": {
        "rh:doc": [
RammusXu commented 7 years ago
RammusXu commented 7 years ago

Backup mongodb

docker exec -it restheartdocker_mongodb_1 mongodump
docker cp restheartdocker_mongodb_1:/dump mongo-dump
mv mongo-dump/dump mongo-dump/dump-$(date +%Y%m%d_%H%M%S)