cocomon

Dart

How generated Dart code is shaped and how to open runtime adapters correctly.

Dart

After generate, the normal path is to work through the generated client rather than through handwritten records and raw SQL strings.

Typical runtime shape

import 'generated/comon_orm_client.dart';

Future<void> main() async {
  final db = await GeneratedComonOrmClientSqlite.open();

  try {
    final user = await db.user.create(
      data: const UserCreateInput(
        email: 'alice@example.com',
        name: 'Alice',
      ),
    );

    final users = await db.user.findMany();

    print(user.email);
    print(users.length);
  } finally {
    await db.close();
  }
}

What the generated surface includes

  • typed models and scalar enums
  • WhereInput and WhereUniqueInput types
  • CRUD delegates such as findMany, create, update, delete, and upsert
  • relation-aware nested create and update inputs
  • select, include, orderBy, distinct, skip, take, aggregate, and group-by support

On this page