The name of the collection
const stash = await Stash.connect();
const movies = await stash.loadCollection('movies');
movies.name // 'movies'
A cryptographically secure identifier for the collection
This field is generated using your profile's naming key, and the name of the collection and is used when communicating with CipherStash.
The underlying CollectionSchema
for the collection
Delete a record by id
const stash = await Stash.connect();
const movies = await stash.loadCollection<Movie>('movies');
const movie = await movies.delete(...);
the id of the document to be deleted
Retrieve a record by id
const stash = await Stash.connect();
const movies = await stash.loadCollection<Movie>('movies');
const movie = await movies.get(...);
the id of the document to be retrieved
A promise containing the retrieved document if it exists
Retrieve an array of records from an array of ids
const stash = await Stash.connect();
const movies = await stash.loadCollection<Movie>('movies');
const [ first, second ] = await movies.getAll([ ..., ... ]);
An array or buffer of ids to be retrieved
Upsert a record into the collection
const stash = await Stash.connect();
const movies = await stash.loadCollection<Movie>('movies');
const id = await movies.put({
title: 'CipherStash Reloaded',
year: 2022
});
the document to be inserted into
A promise resolving with the id of the inserted document
Put multiple records into a collection using an async generator
async function* fetchMovies() {
const first = await fetchFirstMovie();
yield first;
const second = await fetchSecondMovie();
yield second;
}
const stash = await Stash.connect();
const movies = await stash.loadCollection<Movie>('movies');
await movies.putStream(fetchMovies);
AsyncIterator that yields the docs to be inserted
A promise that resolves with the number of documents inserted
Query a collection based on its schema
const stash = await Stash.connect();
const movies = await stash.loadCollection(movieSchema);
const { documents } = await movies.query(
movie => movie.year.lte(1960)
);
a callback function for building a query, or a query options object
an optional object containing query options
A QueryResult
object containing the documents, aggregates and the time query took
Generated using TypeDoc
The UUID of the collection used internally
As this field is for internal use only, use the
Collection.name
field if you need to reference a collection.Collection.name