-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpython_sg_feed.py
executable file
·34 lines (28 loc) · 1.09 KB
/
python_sg_feed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
import sys
sys.path.insert(0, r'/usr/local/lib/python2.7/site-packages/')
import requests #Python Request libary for handling streaming HTTP link is here: http://docs.python-requests.org/en/master/
url_param = "?feed=continuous&include_docs=true&since=0"
r = requests.get('http://localhost:4984/sync_gateway/_changes'+url_param, stream=True)
for line in r.iter_lines():
if line:
print line
#docs on _change feed options https://developer.couchbase.com/documentation/mobile/1.4/references/sync-gateway/rest-api/index.html#/database
'''
### FILTER BY CHANNELS ###
channels = 'bob,water,cake'
url_param = url_param +'&filter=sync_gateway/bychannel&channels='+channels
'''
'''
### Saving My App's Checkpoint inside Sync Gateway ###
HTTP/1.1 PUT or GET
Content-Type: application/json
http://{hostname}:4984/{DB}/_local/my_check_point_{ip address of app}
{
"_id":"my_check_point_8.8.8.8",
"_rev":"1-0",
"datetime":"2016-12-04 17:34:57",
"seq":"5"
}
Docs on local docs: https://developer.couchbase.com/documentation/mobile/1.4/references/sync-gateway/rest-api/index.html#/document
'''