Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Prisma ORM Advanced Techniques

Prisma ORM Advanced Techniques

Production database patterns with Prisma for Google Antigravity IDE

PrismaDatabaseORMBackend
by Antigravity AI
⭐0Stars
👁️2Views
.antigravity
# Prisma ORM Advanced Techniques for Google Antigravity

Master database management with Prisma ORM in Google Antigravity IDE. This comprehensive guide covers schema design, relations, transactions, raw queries, middleware patterns, and performance optimization techniques for building robust database layers.

## Configuration

Configure your Antigravity environment for Prisma:

```typescript
// .antigravity/prisma.ts
export const prismaConfig = {
  features: {
    transactions: true,
    middleware: true,
    rawQueries: true,
    extensions: true
  },
  optimization: {
    connectionPooling: true,
    queryLogging: "development"
  }
};
```

## Schema Design

Define robust database schemas:

```prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fullTextSearch", "relationJoins"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  name      String?
  role      Role     @default(USER)
  posts     Post[]
  profile   Profile?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  @@index([email])
  @@map("users")
}

model Post {
  id          String     @id @default(cuid())
  title       String
  content     String?
  published   Boolean    @default(false)
  author      User       @relation(fields: [authorId], references: [id], onDelete: Cascade)
  authorId    String
  categories  Category[]
  viewCount   Int        @default(0)
  createdAt   DateTime   @default(now())
  updatedAt   DateTime   @updatedAt

  @@index([authorId])
  @@index([published, createdAt])
  @@map("posts")
}

enum Role {
  USER
  ADMIN
  MODERATOR
}
```

## Transaction Patterns

Handle complex operations atomically:

```typescript
import { PrismaClient, Prisma } from "@prisma/client";

const prisma = new PrismaClient();

async function transferCredits(fromUserId: string, toUserId: string, amount: number) {
  return prisma.$transaction(async (tx) => {
    const sender = await tx.user.update({
      where: { id: fromUserId },
      data: { credits: { decrement: amount } }
    });

    if (sender.credits < 0) {
      throw new Error("Insufficient credits");
    }

    const recipient = await tx.user.update({
      where: { id: toUserId },
      data: { credits: { increment: amount } }
    });

    await tx.transaction.create({
      data: {
        fromUserId,
        toUserId,
        amount,
        type: "TRANSFER"
      }
    });

    return { sender, recipient };
  }, {
    isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
    maxWait: 5000,
    timeout: 10000
  });
}
```

## Middleware Extensions

Add cross-cutting concerns:

```typescript
const prisma = new PrismaClient().$extends({
  query: {
    $allModels: {
      async $allOperations({ model, operation, args, query }) {
        const start = performance.now();
        const result = await query(args);
        const duration = performance.now() - start;

        if (duration > 100) {
          console.warn(`Slow query: ${model}.${operation} took ${duration}ms`);
        }

        return result;
      }
    }
  }
});

const prismaWithSoftDelete = prisma.$extends({
  query: {
    post: {
      async delete({ args, query }) {
        return prisma.post.update({
          where: args.where,
          data: { deletedAt: new Date() }
        });
      },
      async findMany({ args, query }) {
        args.where = { ...args.where, deletedAt: null };
        return query(args);
      }
    }
  }
});
```

## Query Optimization

Write efficient queries:

```typescript
async function getPostsWithCounts() {
  return prisma.post.findMany({
    where: { published: true },
    select: {
      id: true,
      title: true,
      createdAt: true,
      author: {
        select: { name: true, email: true }
      },
      _count: {
        select: { comments: true, likes: true }
      }
    },
    orderBy: { createdAt: "desc" },
    take: 20
  });
}

async function getPaginatedPosts(cursor?: string, take = 10) {
  const posts = await prisma.post.findMany({
    take: take + 1,
    cursor: cursor ? { id: cursor } : undefined,
    orderBy: { createdAt: "desc" },
    include: { author: true }
  });

  const hasMore = posts.length > take;
  const items = hasMore ? posts.slice(0, -1) : posts;
  const nextCursor = hasMore ? items[items.length - 1].id : null;

  return { items, nextCursor, hasMore };
}
```

## Best Practices

Follow these guidelines for Prisma:

1. **Use transactions** - Atomic operations for consistency
2. **Index strategically** - Add indexes for common queries
3. **Select only needed fields** - Reduce data transfer
4. **Use cursor pagination** - Better performance than offset
5. **Extend with middleware** - Cross-cutting concerns
6. **Monitor slow queries** - Log and optimize

Google Antigravity IDE provides intelligent Prisma schema suggestions and query optimization tips.

When to Use This Prompt

This Prisma prompt is ideal for developers working on:

  • Prisma applications requiring modern best practices and optimal performance
  • Projects that need production-ready Prisma code with proper error handling
  • Teams looking to standardize their prisma development workflow
  • Developers wanting to learn industry-standard Prisma patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their prisma implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the Prisma code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this Prisma prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For Prisma projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...