orm 4.0.0-alpha.0 copy "orm: ^4.0.0-alpha.0" to clipboard
orm: ^4.0.0-alpha.0 copied to clipboard

◭ Next-generation ORM for Dart & Flutter | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB.

example/main.dart

import 'dart:typed_data';

import 'package:orm/engines/binary.dart';
import 'package:orm/orm.dart';

import '../prisma/dart/client.dart';
import '../prisma/dart/types.dart';

void main() async {
  final engine = BinaryEngine(
    datasource: 'db',
    schema: schema,
    binary: 'prisma/dart/prisma-query-engine',
    url: Uri.parse('postgresql://seven@localhost:5432/prisma-dart'),
  );
  final prisma = PrismaClient(engine: engine);

  await prisma.$transaction((prisma) async {
    // Delete all users and posts.
    await prisma.post.deleteMany();
    await prisma.user.deleteMany();

    await prisma.user.create(
      data: PrismaUnion.$2(
        UserUncheckedCreateInput(
          name: 'Seven',
          price: Decimal.fromInt(1),
          size: BigInt.zero,
          bytes: Uint8List(0),
          count: 1,
          posts: PostUncheckedCreateNestedManyWithoutAuthorInput(
            create: PrismaUnion.$2(
              PrismaUnion.$1([
                PostCreateWithoutAuthorInput(title: 'Post 1'),
                PostCreateWithoutAuthorInput(title: 'Post 2'),
              ]),
            ),
          ),
        ),
      ),
    );
  });

  final users = await prisma.user
      .findMany(select: UserSelect(id: true, name: true, $count: true));
  final post = await prisma.post.findFirstOrThrow(
    include: PostInclude(author: true),
  );

  print(users);
  print(post.author);

  await prisma.$disconnect();
}
213
likes
0
pub points
88%
popularity

Publisher

verified publisherodroe.dev

◭ Next-generation ORM for Dart & Flutter | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

github.com
opencollective.com
www.patreon.com

License

unknown (license)

Dependencies

code_builder, dart_style, decimal, json_rpc_2, path, recase, retry, stdweb, stream_channel

More

Packages that depend on orm