5.2 Creating a Collection That Has Custom Metadata
You use a PUT
collection operation to create a document
collection that has custom metadata. You provide the metadata in the request
body.
The request body of a PUT
collection operation is a
SODA collection specification. It is JSON data that
specifies the metadata for the new collection. If the body is empty then the
collection is created using the default metadata.
If a collection with the same name already exists then it is simply opened. If the custom metadata provided does not match the metadata of the existing collection then the collection is not opened and an error is raised. (To match, all metadata fields must have the same values.)
Example 5-2 Creating a Collection That Has Custom Metadata
This example creates a collection with the custom metadata that is in
file metadata.json
.
curl -i -X PUT --data-binary @metadata.json -H "Content-Type: application/json" http://localhost:8080/ords/database-schema/soda/latest/MyCustomCollection
Here is example content of file metadata.json
. It is the same as the
default metadata, except that the key column assignment method is set to
CLIENT
. (The default metadata for a collection is presented in
Default Collection Metadata in Oracle Database
Introduction to Simple Oracle Document Access
(SODA).)
{ "keyColumn" : { "name" : "ID",
"assignmentMethod" : "CLIENT" },
"contentColumn" : { "name" : "JSON_DOCUMENT"},
"versionColumn" : { "name" : "VERSION",
"method" : "UUID" },
"lastModifiedColumn" : { "name" : "LAST_MODIFIED" },
"creationTimeColumn" : { "name" : "CREATED_ON" } }
Related Topics
Parent topic: SODA Collection Configuration Using Custom Metadata