db_changes: List changes to a database.

Description Usage Arguments Value Examples

View source: R/db_changes.R

Description

Of course it doesn't make much sense to use certain options in _changes. For example, using feed=longpoll or continuous doesn't make much sense within R itself.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
db_changes(
  cushion,
  dbname,
  descending = NULL,
  startkey = NULL,
  endkey = NULL,
  since = NULL,
  limit = NULL,
  include_docs = NULL,
  feed = "normal",
  heartbeat = NULL,
  filter = NULL,
  as = "list",
  ...
)

Arguments

cushion

A Cushion object. Required.

dbname

Database name. (character)

descending

Return in descending order? (logical)

startkey

Document ID to start at. (character)

endkey

Document ID to end at. (character)

since

Start the results from the change immediately after the given sequence number.

limit

Number document IDs to return. (numeric)

include_docs

(character) If "true", returns docs themselves, in addition to IDs

feed

Select the type of feed. One of normal, longpoll, or continuous. See description. (character)

heartbeat

Period in milliseconds after which an empty line is sent in the results. Only applicable for longpoll or continuous feeds. Overrides any timeout to keep the feed alive indefinitely. (numeric (milliseconds))

filter

Reference a filter function from a design document to selectively get updates.

as

(character) One of list (default) or json

...

Curl args passed on to HttpClient

Value

Either a list of json (depending on as parameter), with keys:

Examples

 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
## Not run: 
user <- Sys.getenv("COUCHDB_TEST_USER")
pwd <- Sys.getenv("COUCHDB_TEST_PWD")
(x <- Cushion$new(user=user, pwd=pwd))

if ("leoalion" %in% db_list(x)) {
  invisible(db_delete(x, dbname="leoalion"))
}
db_create(x, dbname='leoalion')

# no changes
res <- db_changes(x, dbname="leoalion")
res$results

# create a document
doc1 <- '{"name": "drink", "type": "water", "score": 5}'
doc_create(x, dbname="leoalion", doc1, docid="awater")

# now there's changes
res <- db_changes(x, dbname="leoalion")
res$results

# as JSON
db_changes(x, dbname="leoalion", as='json')

## End(Not run)

sofa documentation built on July 8, 2020, 6:53 p.m.