Schema-derived types
Fields, primary keys, query conditions, Yukari rows, and JSON output derive from one model definition.

import { Toshihiko, Type } from 'toshihiko';
const database = new Toshihiko('mysql', {
database: 'app',
host: '127.0.0.1',
password: 'secret',
username: 'root',
});
const User = database.define('users', [
{
name: 'id',
column: 'user_id',
type: Type.Integer,
primaryKey: true,
autoIncrement: true,
},
{ name: 'name', type: Type.String },
], {
methods: {
findByName(name: string) {
return this.where({ name }).findOne();
},
},
});
const user = User.build({ name: 'Alice' });
await user.insert();
const found = await User.findByName('Alice');The schema is both runtime mapping and TypeScript input. Toshihiko infers field values, primary keys, query conditions, row properties, and custom Model methods without a separately maintained row interface.
Project status
Toshihiko v2 is under active development. Current packages use prerelease versions and require Node.js 22 or newer.
Toshihiko is a character from Touhou Warring States Nights, a collaborative Touhou fan work. The name has been part of the project since its first release in 2014.