Documents identified by the query are updated
by patching their JSON with value
.
This is native with MongoDB and SQLite and is
emulated for Elasticsearch and CouchDB using
SQLite/JSON1, and uses a plpgsql function for
PostgreSQL.
Arguments
- src
Source object, result of call to any of functions
src_mongo()
,src_sqlite()
,src_elastic()
,src_couchdb()
orsrc_postgres()
- key
(character) A key as name of the container (corresponds to parameter
collection
for MongoDB,dbname
for CouchDB,index
for Elasticsearch and to a table name for SQLite and for PostgreSQL)- value
The data to be created in the database: a single data.frame, a JSON string or a list; or the file name or URL of NDJSON documents
- query
(character) A JSON query string, see examples
- ...
Passed on to functions:
CouchDB:
sofa::db_bulk_create()
Elasticsearch: elastic::docs_bulk_update
MongoDB:
mongolite::mongo()
SQLite: ignored
PostgreSQL: ignored
DuckDB: ignored
Examples
if (FALSE) {
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_get(src, "mtcars")
}