@1auth/store

Base storage interface that all store implementations follow.

Overview

Store modules provide a common interface for database operations. All 1auth modules that persist data accept a store option pointing to any compatible implementation.

Available implementations

PackageBackendNotes
@1auth/store-dynamodbAWS DynamoDBServerless, pay-per-request
@1auth/store-postgresPostgreSQLRelational, self-hosted
@1auth/store-sqliteSQLiteEmbedded, local development
@1auth/store-d1Cloudflare D1Edge, serverless SQLite

Common interface

All store implementations provide these methods:

exists(table, filters)

Check if a record exists matching the filters.

Returns: boolean

count(table, filters)

Count records matching the filters.

Returns: number

select(table, filters, fields)

Retrieve a single record.

Returns: Record object or undefined

selectList(table, filters, fields)

Retrieve multiple records.

Returns: Array of record objects

insert(table, values)

Insert a new record.

update(table, filters, values)

Update an existing record.

remove(table, filters)

Delete a record.

Configuration

All stores share common options:

OptionTypeDefaultDescription
clientobjectDatabase client instance
timeToLiveExpireOffsetnumber864000 (10 days)TTL offset in seconds
timeToLiveKeystring"remove"Column/attribute name for TTL