Am 17.01.2014 um 22:13 schrieb Jens Alfke <[email protected]>:

> 
> On Jan 17, 2014, at 12:04 PM, Francisco Garcia <[email protected]> 
> wrote:
> 
>> >  curl -X PUT -d '{"name":"bob","channel_id":"kuku"}' 
>> > http://localhost:4985/rubase/bob
>> {"error":"Unsupported Media Type","reason":"Invalid content type 
>> application/x-www-form-urlencoded"}%
> 
> Look at what the error message says. You need to set the request Content-Type 
> to application/json. (Pretty sure CouchDB would complain the same way.)
> 

arg! shame on me! I ignored that curl was giving me that error because CouchDB 
did work for me:

>  curl -X PUT -d '{"name":"bob","channel_id":"kuku"}' 
> http://couchdb.dev/rubackup/bob2
{"ok":true,"id":"bob2","rev":"1-7fd06dfd6556031ca52a90777ae50ca2"}


> Actually I recommend switching to HTTPie from curl — it makes sending JSON 
> requests vastly easier, including automatically setting the content type.


But that is shell only isn't it? Using curl was for the email, but normally I 
use this Chrome extension:

http://www.getpostman.com/

I highly recommend it for any REST api, it is a breeze to set up different 
authentifications and even more important, to save sample requests

However there is a bug. When I saw the content type error, I thought this 
extension was setting the right type.

Here are some screenshots for you to make it work right (and for my bug report 
to them)

https://www.evernote.com/shard/s44/sh/63f82a12-5e80-40e3-8dcb-eb257eb2e1a0/f90c9cab605b3a03f61fb90b71595e9c
https://www.evernote.com/shard/s44/sh/b8d738d3-cdf9-47dd-b0f9-a17f1c18a906/0271759b0067d93e88668444b6fe051e

Hope you like it, it would be great for once after all your help, being able to 
make you discover something new that eases your workflow


> 
>> 2. I tried the same operation logged as a user. After a while with no 
>> success, explored the docs and noticed that there is no PUT database/document
> 
> Yes, there is. Maybe the docs are wrong; can you show me where it says this?
> 

Here!

http://docs.couchbase.com/sync-gateway/#http-requests

But my mistake was exploring the code like commented some lines above. Even 
I've just found the line for that

https://github.com/couchbase/sync_gateway/blob/master/src/github.com/couchbaselabs/sync_gateway/rest/routing.go#L55



>> 3. I had some documents already in my CouchBase bucket, so I wanted to see 
>> if I could get them listed with 'all_docs'.
> 
> It's possible to make the gateway add metadata to existing docs in the bucket 
> to make them accessible via the gateway. In the database configuration object 
> set the property "importdocs" to true, then restart the gateway.
> 

That will prove very useful within a future. And I've just verified such 
amazingly useful property is not mentioned in the docs:

        http://docs.couchbase.com/sync-gateway


Now looking at generated bucket doc, can't help but have some new doubts:

1. "importdocs", "_sync"... is there any list of Reserved Property Names (along 
design document ids) for CouchBase products that developers could use as 
reference to avoid future conflicts with our documents?

2. I've just understood how to use the sync functions and map a property tot he 
_sync/channels array!

When multiples users access the same bucket and mostly can read only their own 
docs:

        Is the common practice mapping each user its own channel? 

        Should I ideally store always the user name / channel as a prefix of 
every document "_id" instead using a document property? 

                I understand the risk of non random 'id' conflicts using 
properties, but not sure if there they have any advantage

3. Looking at my bucket, noticed that the same document will show a different 
"rev" field  when exploring the bucket through the SDK 

https://www.evernote.com/shard/s44/sh/fdba6cfc-7543-43ba-b0f1-e22c2308d38b/43e99f8eda51ac855e06b2dcb6b9d6a6

Is that  expected? I am concerned about having a mobile app (through gateway) + 
web app (through SDK). The SDK is what I have when using Ruby, but it seems 
dangerous touching documents considering the info inside "_sync". Should I 
prepare to implement my Ruby web app using the gateway? If yes, will CouchRest 
(ruby gem) give us the Gateway-SDK for Ruby?



Well, that makes my day! Thanks to you I learnt a lot today. Have a great 
weekend Jens!

--  Francisco

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/EA319878-F062-406F-A8C4-CB53EC916375%40francisco-garcia.net.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to