Create a Collection with Stash CLI
You can create a collection in your workspace using the stash create-collection
command.
In order to create a collection, you must be logged in.
Synopsis
stash create-collection <name> [--schema=your-schema.json] [--no-schema]
Arguments
The collection name <name>
is mandatory. This is the name of the collection that will be created.
Either the --schema
or --no-schema
argument must be provided when creating a collection.
- If
--no-schema
is provided, the collection will only be usable as a key-value store - If
--schema
is provided, the collection will support searching the fields and indexes specified in the schema
While --no-schema
is supported, providing a schema is necessary to be able to use the rich querying capabilities of CipherStash with your collection.
Examples
Create the movies
collection in your workspace:
Without a schema
$ stash create-collection movies --no-schema
The 'movies' collection has been created.
With a schema
$ echo <<SCHEMA > ./movies.schema.json
{
"type": {
"title": "string",
"runningTime": "uint64",
"year": "uint64"
},
"indexes": {
"exactTitle": { "kind": "exact", "field": "title" },
"runningTime": { "kind": "range", "field": "runningTime" },
"year": { "kind": "range", "field": "year" },
"title": {
"kind": "match",
"fields": ["title"],
"tokenFilters": [
{ "kind": "downcase" },
{ "kind": "ngram", "tokenLength": 3 }
],
"tokenizer": { "kind": "standard" }
}
}
}
SCHEMA
$ stash create-collection movies --schema=movies.schema.json
The 'movies' collection has been created.
Exit Status
The exit status will be 0
if the collection was successfully created.
An exit status of 1
indicates a failure to create the collection, most likely because the credentials were invalid or the server was unavailable, or there was an error in the provided schema definition.
Whenever a non-zero exit status is returned, a helpful error message is printed to standard error.