Closed diegonella closed 6 years ago
Well, that's odd. It seems something related to your CouchDB user permission to write. Could you double check it please? Try using an admin user just to make sure.
Thanks @robsonvn for reply My user is admin, i can see that in when I do the find
MangoQuery: {"selector":{"_id":"82fe410d5ff5e58de58c9bfdca7f0c5b","type":"users"},"sort":[{"type":"asc"}],"limit":1,"use_index":["_design\/mango-indexes","type:asc"]}
Result: {"status":200,"headers":{"version":"1.0","status":200,"x-frame-options":"DENY","x-couch-request-id":"f6a86743fe","server":"CouchDB\/2.1.1 (Erlang OTP\/17)","date":"Sun, 08 Apr 2018 21:44:56 GMT","content-type":"application\/json","cache-control":"must-revalidate","strict-transport-security":"max-age=31536000","x-content-type-options":"nosniff","x-cloudant-request-class":"query","x-cloudant-backend":"bm-cc-us-south-05","via":"1.0 lb1.bm-cc-us-south-05 (Glum\/1.50.4)"},"body":{"docs":[{"_id":"82fe410d5ff5e58de58c9bfdca7f0c5b","_rev":"1-494f18cfd01d4b0349ae7b817509dbb5","name":"Diego","email":"diegonella@gmail","password":"078c007bd92ddec308ae2f5115c1775d","updated_at":"2018-04-08 17:35:52","created_at":"2018-04-08 17:35:52","type":"users"}],"bookmark":"g1AAAABbeJzLYWBgYMpgSmHgKy5JLCrJTq2MT8lPzkzJBYorWBilpZoYGqSYpqWZpppapABxsmVSWkpyonmaQbJpEkgfB0xfDlAHI0gba2lxalFxVhYAhGkZog","warning":"_design\/mango-indexes, type:asc was not used because it is not a valid index for this query."}}
MangoQuery: {"selector":{"$and":[{"_id":"82fe410d5ff5e58de58c9bfdca7f0c5b"},{"_rev":"1-494f18cfd01d4b0349ae7b817509dbb5"}],"type":"users"},"limit":999999999}
Result {"version":"1.0","status":200,"x-frame-options":"DENY","x-couch-request-id":"f6a86743fe","server":"CouchDB\/2.1.1 (Erlang OTP\/17)","date":"Sun, 08 Apr 2018 21:44:56 GMT","content-type":"application\/json","cache-control":"must-revalidate","strict-transport-security":"max-age=31536000","x-content-type-options":"nosniff","x-cloudant-request-class":"query","x-cloudant-backend":"bm-cc-us-south-05","via":"1.0 lb1.bm-cc-us-south-05 (Glum\/1.50.4)"},"body":null}
when I make the query from the console, both queries give results
The library uses the _bulk_docs endpoint, and according to the documentation, the body content should include the modified docs but instead, you're receiving body = null.
Could you manually call the _bulk_docs endpoint and send me the response? You can do it using either curl or postman
I think I know what is going on. When I tried to test this lib using Cloudant I remember I was facing a similar problem. The thing is that if you're using a free version you can do no more than 5 queries per second that was where my tests were failing.
Could you confirm it?
Yes, i have use free plan, but too use couchdb in local and same error. When call /_bulk_docs response: { "error": "forbidden", "reason": "~server_admin access is required for this request~" }
edit1: sorry
I try send by postman POST: HOST.cloudant.com/database/_bulk_docs body: { "docs": [{"_id":"82fe410d5ff5e58de58c9bfdca7f0c5b","_rev":"1-494f18cfd01d4b0349ae7b817509dbb5","name":"Diego","email":"diegonella@gmail","password":"078c007bd92ddec308ae2f5115c1775d","updated_at":"2018-04-08 17:35:52","created_at":"2018-04-08 17:35:52","type":"users"}]}
And result [ { "ok": true, "id": "82fe410d5ff5e58de58c9bfdca7f0c5b", "rev": "2-697513f4c42dcf3e962810a454cfefc4" } ]
Definitely, you won't be able to use this library using Cloudant free version as this library does many requests and easily reaches more than 5 requests per second plus you will fail trying update more than 5 documents at same time
The problem you having using local db is totally different though, it seems permission problems.
and if I do a sleep (1) between the find and the update ?, besides I'm just updating 1 record, I do not finish understanding the cloudant quota
I've tried this with no success, maybe you should try.
If you want to use a free solution you should try deploy a couchdb docker image in a free heroku app.
You can use this docker image https://hub.docker.com/r/robsonvn/couchdb-ssl/
Sorry @robsonvn but run the docker locally, I could do an INSERT
but when I want to list it returns me
QueryException no-index or no matching fields order / selector
I do not know what I'm doing wrong :(
Do you mind sending me the configs you're using in your .env?
this is my .env
DB_CONNECTION=couchdb
DB_HOST=127.0.0.1
DB_PORT=5984
DB_DATABASE=mydatabase
DB_CONNECTION_TYPE=stream
DB_USERNAME=root
DB_PASSWORD=root
DB_LOGGING=true
@diegonella can you pull this boiler plated and see what happens ?
The problem is when use connection type stream, via socket with project and couchdb in same server, running ok. When use stream i have error with couchdb local or remote.
Thank @diegonella,
I'll have check on it.
Any special reason of using "stream" ?
it was my mistake, thinking that I had to configure via stream for remote hosts
Hi, I have next error when update row
(1/1) ErrorExceptionInvalid argument supplied for foreach()
in Collection.php (line 122) at HandleExceptions->handleError(2, 'Invalid argument supplied for foreach()', '/Applications/MAMP/htdocs/laravel/webapp/vendor/robsonvn/laravel-couchdb/src/Collection.php', 122, array('selector' => array('$and' => array(array('_id' => '82fe410d5ff5e58de58c9bfdca7f0c5b'), array('_rev' => '1-494f18cfd01d4b0349ae7b817509dbb5'))), 'values' => array('_id' => '82fe410d5ff5e58de58c9bfdca7f0c5b', '_rev' => '1-494f18cfd01d4b0349ae7b817509dbb5', 'name' => 'Diego Gone', 'email' => 'diegonella@gmail', 'password' => '078c007bd92ddec308ae2f5115c1775d', 'updated_at' => '2018-04-08 17:36:51', 'created_at' => '2018-04-08 17:35:52', 'type' => 'users'), 'options' => array(), 'query' => object(MangoQuery), 'result' => object(Response), 'documents' => null))in Collection.php (line 122)
My code is
$usr = \App\User::find('82fe410d5ff5e58de58c9bfdca7f0c5b');
$usr->name = "Diego Gone";
$usr->save();
Laravel Framework 5.4.36, PHP 7.1, CouchDB 2.1.1 on Cloudant, but in local couchdb 2.1.1 same error