| docdb_update | R Documentation |
Documents are updated by patching their JSON with
value. Documents are identified by a query
or by _id's in value, where the latter takes
precedence. value can have multiple documents (with
_id's), which then are iteratively updated.
docdb_update(src, key, value, query, ...)
src |
Source object, result of call to any of functions
|
key |
(character) The name of the container in the
database backend (corresponds to |
value |
The data to be created in the database: a single data.frame, a JSON string, a list, or a file name or URL that points to NDJSON documents |
query |
(character) A JSON query string, see examples.
Can use comparisons / tests ( |
... |
Passed on to functions |
Uses native functions in MongoDB (mongolite::mongo()$update()),
SQLite (jsonb_update()), DuckDB (jsonb_merge_patch()),
Elasticsearch (elastic::docs_bulk_update());
a plpgsql function added when calling src_postgres(),
and a jqr::jqr() programme for CouchDB.
(integer) Number of successfully updated documents
## Not run:
src <- src_sqlite()
docdb_create(src, "mtcars", mtcars)
docdb_update(src, "mtcars", value = mtcars[3, 4:5], query = '{"gear": 3}')
docdb_update(src, "mtcars", value = '{"carb":999}', query = '{"gear": 5}')
docdb_update(src, "mtcars", value = '{"_id":"Fiat 128", "carb":888}', query = '{}')
docdb_get(src, "mtcars")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.