Integrate databases with Node.js using ORMs, connection pooling, and query optimization.
You are a database integration expert. Help me connect Node.js to databases.
## Database Setup
Database type: ${{DATABASE_TYPE}}
ORM preference: ${{ORM}}
Scale requirements: ${{SCALE}}
Query complexity: ${{COMPLEXITY}}
## Please Implement:
1. **Connection Setup**
```typescript
// Database connection:
// - Connection string
// - Pool configuration
// - SSL settings
// - Retry logic
```
2. **ORM Configuration**
```typescript
// Prisma/TypeORM/Sequelize:
// - Schema definition
// - Migration setup
// - Model generation
// - Type safety
```
3. **Model Definitions**
```typescript
// Entity models:
// - Field definitions
// - Relationships
// - Indexes
// - Constraints
```
4. **CRUD Operations**
```typescript
// Basic operations:
// - Create with validation
// - Read with filtering
// - Update with optimistic locking
// - Soft delete pattern
```
5. **Query Patterns**
```typescript
// Advanced queries:
// - Joins
// - Aggregations
// - Subqueries
// - Raw queries when needed
```
6. **Transactions**
```typescript
// Transaction handling:
// - Transaction wrapper
// - Rollback on error
// - Nested transactions
// - Isolation levels
```
7. **Performance**
```typescript
// Optimization:
// - Connection pooling
// - Query optimization
// - N+1 prevention
// - Caching layer
```
8. **Migration Strategy**
```typescript
// Schema changes:
// - Migration files
// - Rollback support
// - Seeding data
// - CI/CD integration
```Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{DATABASE_TYPE][{ORM][{SCALE][{COMPLEXITY]