Skip to contents

A message is emitted if the container key already exists.


docdb_create(src, key, value, ...)



Source object, result of call to any of functions src_mongo(), src_sqlite(), src_elastic(), src_couchdb() or src_postgres()


(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)


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:


(integer) Number of successfully created documents


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).


if (FALSE) {
src <- src_sqlite()
docdb_create(src, key = "diamonds_small",
  value =[1:3000L,]))
head(docdb_get(src, "diamonds_small"))
docdb_create(src, key = "contacts", value = contacts)
docdb_get(src, "contacts")[["friends"]]