Can not understand couchbase todolite demo

238 views Asked by At

github.com/couchbaselabs/ToDoLite-Android

Q 1: https://github.com/couchbaselabs/ToDoLite-Android/blob/master/ToDoLite/src/main/java/com/couchbase/todolite/document/Profile.java

profile.java have code :

Document document = database.getDocument("p:" + userId);

But when I see _admin xxx.ooo. com : 4985/_admin/db/ documents have records, but can not see p:xxxooo document. Debug trace can see document id: p:xxxxooo get. But document file can not find. why? or how to see?

http://postimg.org/image/v267oc29x/

github.com/couchbaselabs/ToDoLite-Android/blob/master/sync-gateway-config.json

Q2: use facebook login, login success. http:/xxx.ooo.com:4985/_admin/db/...../users

I can see users be added for facebook logined.

But I try to debug or trace can not find code to add user.

Anyone know where this code or how to do?

Thank you ~~

1

There are 1 answers

0
sueboy On

A2: Beacuse this java POST something to _facebook. Then sync_gateway have setting about

"facebook" : {
   "register" : true
}

So sync_gateway maybe write some code add user to users.

See this java

D:\Android\project\ToDoLite-Android\libraries\couchbase-lite-java-core\src\main\java\com\couchbase\lite\replicator\ReplicationInternal.java

Find this

Future future = sendAsyncRequest("POST", loginPath, loginParameters, new RemoteRequestCompletionBlock() {

This is my debug values

loginPath         /_facebook
loginParameters   "access_token" -> 
                  "CAAHQmreG........"


url  http://ooo.xxxx.com:4984/todos/_facebook

http://developer.couchbase.com/mobile/develop/guides/sync-gateway/administering-sync-gateway/authenticating-users/index.html

So this is why auto add user to users.

You can delete user

DELETE oooxxx.com:4985/todos/_user/[email protected]

Then set deubg point at

Future future = sendAsyncRequest("POST", loginPath, loginParameters, new RemoteRequestCompletionBlock() {

then check

http://xxxx.oooo.com:4985/_admin/db/todos/users

relogin agoin, debug stop that java, check users no any. then F8 . user be add to users. this is for my debug track.

==========

D:\Android\project\ToDoLite-Android\libraries\couchbase-lite-java-core\src\main\java\com\couchbase\lite\replicator\Replication.java

protected ReplicationInternal replicationInternal;

D:\Android\project\ToDoLite-Android\libraries\couchbase-lite-java-core\src\main\java\com\couchbase\lite\replicator\ReplicationInternal.java

ReplicationInternal() => initializeStateMachine()

ReplicationInternal.this.start();

start() => goOnlineInitialStartup() => checkSession() => checkSessionAtPath("/_session") => login()

Future future = sendAsyncRequest("POST", loginPath, loginParameters, new RemoteRequestCompletionBlock() {