A collection is required before you can insert or query data in CipherStash.
To create a new collection, you must define a schema for the collection, and then use
Stash::Client#create_collection to create the collection on the server.
The simplest, and most compatible, way to create a schema is by parsing a JSON schema definition and loading it straight in. Taking the ubiquitous example movies schema, we can do this:
require "cipherstash/client" require "json" require "open-uri" schema_data = URI.open("https://cipherstash.com/examples/movies.schema.json").read schema_def = JSON.parse(schema_data) stash = CipherStash::Client.new stash.create_collection("movies", schema_def)
A schema definition is most commonly loaded from JSON, however you can create the equivalent structure directly in Ruby code if you desire. The structure is simply a Ruby hash which would be equivalent to the same schema if it were parsed from JSON. The main thing to bear in mind is that all the keys in the hashes must be strings.