encryptedTable
API reference for encryptedTable
Function: encryptedTable()
function encryptedTable<T>(tableName, columns): EncryptedTable<T> & T;Defined in: .tmp-stack/packages/stack/src/schema/index.ts:533
Define an encrypted table schema.
Creates a EncryptedTable that maps a database table name to a set of encrypted
column definitions. Pass the resulting object to Encryption({ schemas: [...] })
when initializing the client.
The returned object is also a proxy that exposes each column builder directly,
so you can reference columns as users.email when calling encrypt, decrypt,
and encryptQuery.
Type Parameters
T
T extends EncryptedTableColumn
Parameters
tableName
string
The name of the database table this schema represents.
columns
T
An object whose keys are logical column names and values are EncryptedColumn from encryptedColumn, or nested objects whose leaves are EncryptedField from encryptedField.
Returns
EncryptedTable<T> & T
A EncryptedTable<T> & T that can be used as both a schema definition
and a column accessor.
Example
import { encryptedTable, encryptedColumn } from "@cipherstash/stack/schema"
const users = encryptedTable("users", {
email: encryptedColumn("email").equality().freeTextSearch(),
address: encryptedColumn("address"),
})
// Use as schema
const client = await Encryption({ schemas: [users] })
// Use as column accessor
await client.encrypt("hello@example.com", { column: users.email, table: users })