Skip to content

ToshihikoYet another simple ORM for Node.js.

Toshihiko

A first model ​

typescript
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.

Choose a path ​

  • Getting started builds a complete MySQL CRUD flow.
  • Core concepts explains Toshihiko, Model, Query, Yukari, Adapter, and Cache.
  • Model definition covers fields, primary keys, validators, defaults, and custom methods.
  • Querying documents conditions, ordering, projections, limits, and result forms.
  • Migrating from v1 maps existing Toshihiko applications to the v2 packages and Promise API.
  • API reference lists the public classes, methods, and helper types.

About the name ​

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.

Released under the MIT License.