Skip to content

API reference ​

The API reference describes the public runtime objects, call signatures, return types, and extension contracts. Use the guides for task-oriented explanations.

The pages below explain the public API with examples and usage guidance. When you need every exported symbol or an exact generic signature, use the complete type index, which is generated from the TypeScript source with an English interface.

Runtime object map ​

text
Toshihiko
└── Model returned by define()
    ├── Query returned by where(), fields(), limit(), order(), and conn()
    └── Yukari returned by build() or a query

Field ── compiles a schema entry and delegates value conversion to Type

Core API ​

ReferenceWhat it covers
ToshihikoConstruction, database selection, define(), raw execution, and database metadata
ModelSchema metadata, custom methods, query entry points, transactions, and helper types
QueryConditions, projection, ordering, limits, execution, overloads, and return types
YukariRow state, validation, persistence, serialization, and lifecycle errors
Field and TypeSchema entries, compiled fields, built-in types, validators, and custom field types

Extension API ​

These pages are for Adapter and Cache package authors. Applications using a published Adapter do not need these contracts.

ReferencePackage
Adaptertoshihiko and @toshihiko/base-adapter
Cachetoshihiko, @toshihiko/base-cache, Redis, and Memcached packages
MySQL Adapter@toshihiko/mysql-adapter
SQL utilities@toshihiko/sql-utils and the compatibility Escaper object

Reference conventions ​

  • Signatures show the public TypeScript surface. Adapter-specific generics are replaced with descriptive names where that makes the contract easier to read.
  • Methods return Promises whenever work can reach an Adapter or Cache.
  • readonly in a return type describes the TypeScript contract. It does not freeze the runtime value.
  • Compatibility aliases are identified explicitly. They remain supported but are not the primary spelling in examples.
  • Model and Query methods that depend on an Adapter preserve that Adapter's connection and result types.

Package entry points ​

PackageRuntime exports
toshihikoToshihiko, Type, Adapter, Escaper
@toshihiko/base-adapterAdapter, extend
@toshihiko/base-cacheCache
@toshihiko/mysql-adapterMySQLAdapter, MySQLSqlBuilder
@toshihiko/redis-cacheRedisCache, create
@toshihiko/memcached-cacheMemcachedCache, create
@toshihiko/sql-utilsescape, escapeLike, sqlNameToColumn

All packages use CommonJS at runtime and publish TypeScript declarations.

Released under the MIT License.