1
我試圖通過它們的HTTP接口刪除MongoLab Services中託管的我的MongoDb數據庫集合中的多個文檔。這裏是我試圖實現它的CURL請求MongoLab通過CURL/Golang-HTTP刪除使用HTTP PUT的多個集合
curl -H "Content-Type: application/json" -X PUT "https://api.mongolab.com/api/1/databases/mydb/collections/mycoll?q={\"person\":\"554b3d1ae4b0e2832aeeb6af\"}&apiKey=xxxxxxxxxxxxxxxxx"
我基本上想要從集合中刪除具有匹配查詢的所有文檔。 Mongolab doc http://docs.mongolab.com/restapi/#view-edit-delete-document建議"Specifying an empty list in the body is equivalent to deleting the documents matching the query."
。但是,我如何發送PUT請求正文中的空列表?
下面是使用實現上述PUT請求
client := &http.Client{}
postRequestToBeSentToMongoLab, err := http.NewRequest("PUT","https://api.mongolab.com/api/1/databases/mydb/collections/mycoll?q={\"person\":\"554b3d1ae4b0e2832aeeb6af\"}&apiKey=xxxxxxxxxxxxxxxxx",nil)
postRequestToBeSentToMongoLab.Header.Set("Content-Type", "application/json") //http://stackoverflow.com/questions/24455147/go-lang-how-send-json-string-in-post-request
responseFromMongoLab, err := client.Do(postRequestToBeSentToMongoLab)
它返回null
是在兩種情況下(由Golang和CURL PUT請求的情況下)的Golang代碼IM。如何獲得這個工作,以便刪除與查詢匹配的所有文檔?