CipherStash
CipherStash Documentation

Querying Records

To perform queries over your encrypted records, you can use the query method.

For example, to find a user by email address:

User.query(email: "person@example.com")

This will return an ActiveStash::Relation which extends ActiveRecord::Relation so you can chain most methods as you normally would!

To constrain by multiple fields, include them in the hash:

User.query(email: "person@example.com", verified: true)

To order by dob, do:

User.query(email: "person@example.com).order(:dob)

Or to use limit and offset:

User.query(verified: true).limit(10).offset(20)

This means that ActiveStash should work with pagination libraries like Kaminari.

You also, don’t have to provide any constraints at all and just use the encrypted indexes for ordering!

To order all records by dob descending and then created_at, do (note the call to query with no args first):

User.query.order(dob: :desc, :created_at)

For more information visit the ActiveStash Ruby docs.