| docdb_create {nodbi} | R Documentation | 
Create documents in a database
Description
A message is emitted if the container key already exists.
Usage
docdb_create(src, key, value, ...)
Arguments
| 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 | 
| ... | Passed to functions  | 
Details
An error is raised for document(s) in value when their
_id already exist(s) in the collection key;
use docdb_update() to update such document(s).
Value
(integer) Number of successfully created documents
Identifiers
If value is a data.frame that has a column _id,
or is a JSON string having a key _id at root level,
or is a list having an item _id at its top level,
this will be used as _id's and primary index
in the database. If there are no such _id's in value,
row names (if any exist) of value will be used as _id's,
otherwise random _id's will be created (using
uuid::UUIDgenerate() with use.time = TRUE for
SQLite and PostgreSQL, or using DuckDB's built-in uuid()).
Examples
## Not run: 
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"]]
## End(Not run)