CipherStash
CipherStash Documentation

Importing and Querying Sources

Typically your application will store sources in your collections as they’re created by your application. For initial setup, or migration, though, it’s often useful to be able to bulk-import existing data.

Import

Sources to be imported should be saved in a JSON array. Our movies data would look something like this:

[
  {
    title: "Star Trek: The Motion Picture",
    year: 1979,
    runningTime: 132
  },
  {
    title: "Star Trek II: The Wrath of Khan",
    year: 1982,
    runningTime: 113
  },
  {
    title: "Star Trek III: The Search for Spock",
    year: 1984,
    runningTime: 105
  }
  // ... and so on
]

There’s a pre-populated list of thousands of movies available from https://cipherstash.com/examples/movies.data.json. You can download that file if you want to take a look at it, but when we’re importing you can just pass the URL directly to stash, like this:

stash collection import --name movies --data https://cipherstash.com/examples/movies.data.json

This will take a little while (and give your CPU some exercise), because the import process involves parsing and encrypting all the sources before they get sent to CipherStash. Once the command returns, your data is imported and ready to go.

Query Data from the CLI

In addition to all its other fabulous features, you can also use stash to search your CipherStash collections. While this is not intended as a replacement for your application, it is useful to test out queries during development.

To query our movies collection for all the Star Treks, we can use the following command:

stash query --collection movies --where "title match :trek" --var trek="Star Trek"

This will display a table with the titles, release year, and running time in minutes of all the many, many Star Trek movies.

It’s Alive!

Congratulations, you’ve successfully configured CipherStash for your local machine, created a collection, and imported data into it. Further tutorials and reference information can be found in the chapter list.