dataset
dataset [GLOBAL_OPTIONS] VERB OPTIONS COLLECTION_NAME [PRAMETER …]
dataset command line interface supports creating JSON object collections and managing the JSON object documents in a collection.
When creating new documents in the collection or updating documents in the collection the JSON source can be read from the command line, a file or from standard input.
A word about “keys”. dataset uses the concept of key/values for storing JSON documents where the key is a unique identifier and the value is the object to be stored. Keys must be lower case alpha numeric only. Depending on storage engines there are issues for keys with punctation or that rely on case sensitivity. E.g. The pairtree storage engine relies on the host file system. File systems are notorious for being picky about non-alpha numeric characters and some are not case sensistive.
A word about “GLOBAL_OPTIONS” in v2 of dataset. Originally all
options came after the command name, now they tend to come after the
verb itself. This is because context counts in trying to remember
options (at least for the authors of dataset). There are three
“GLOBAL_OPTIONS” that are exception and they are -version
,
-help
and -license
. All other options come
after the verb and apply to the specific action the verb implements.
There are currently three support storage options for JSON documents in a dataset collection.
STORAGE TYPE are specified as a DSN URI except for pairtree which is just “pairtree”.
dataset help init
dataset init my_objects.ds
dataset model my_objects.ds
dataset help create
dataset create my_objects.ds "123" '{"one": 1}'
dataset create my_objects.ds "234" mydata.json
cat <<EOT | dataset create my_objects.ds "345"
{
"four": 4,
"five": "six"
}
EOT
dataset update my_objects.ds "123" '{"one": 1, "two": 2}'
dataset delete my_objects.ds "345"
dataset keys my_objects.ds
This is an example of initializing a Pairtree JSON documentation collection using the environment.
dataset init '${C_NAME}' pairtree
In this case ‘${C_NAME}’ is the name of your JSON document read from the environment varaible C_NAME.
To specify Postgres as the storage for your JSON document collection. You’d use something like –
dataset init '${C_NAME}' \\
'postgres://${USER}@localhost/${DB_NAME}?sslmode=disable'
In this case ‘${C_NAME}’ is the name of your JSON document read from the environment varaible C_NAME. USER is used for the Postgres username and DB_NAME is used for the Postgres database name. The sslmode option was specified because Postgres in this example was restricted to localhost on a single user machine.
dataset 2.2.4