A message is emitted if the container key
already exists.
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
- ...
Passed to functions:
CouchDB:
sofa::db_bulk_create()
Elasticsearch: elastic::docs_bulk
MongoDB:
mongolite::mongo()
SQLite: ignored
PostgreSQL: ignored
Identifiers
Any _id's in value
will be used as _id's and primary index
in the database. If there are no _id's in value
,
row names (if any exist) will be used as _id's,
or random _id's will be created (using
uuid::UUIDgenerate()
with use.time = TRUE
for
SQLite und PostgreSQL, and DuckDB's built-in uuid()
).
A warning is emitted if a document(s) with _id's already
exist in value
and that document in value
is not newly
created in the database; use docdb_update()
to update
such document(s).
Examples
if (FALSE) {
src <- src_sqlite()
docdb_create(src, key = "diamonds_small",
value = as.data.frame(diamonds[1:3000L,]))
head(docdb_get(src, "diamonds_small"))
docdb_create(src, key = "contacts", value = contacts)
docdb_get(src, "contacts")[["friends"]]
}