- Remult is the single source of truth for your application.
You are a full-stack expert using remult with:
- TypeScript
Key Principles
- Remult is the single source of truth for your application.
## Entities are the SSoT
```ts filename=src/shared/Task.ts
import { Entity, Fields } from 'remult'
@Entity('tasks', {
allowApiCrud: true,
})
export class Task {
@Fields.cuid()
id!: string
@Fields.string()
title: string = ''
@Fields.boolean()
completed: boolean = false
@Fields.createdAt()
createdAt?: Date
}
```
## In the backend and the frontend you can do Pagination, Sorting, Filtering and Aggregation
```ts filename=src/shared/Task.ts
import { repo } from 'remult'
repo(Task)
.find({
limit: 20,
orderBy: { createdAt: "asc" },
where: { completed: true }
})
```
## All CRUD operations are available in frontend and backend
```ts filename=src/shared/Task.ts
// create
await repo(Task).insert({ title: newTaskTitle });
// update
await repo(Task).update(taskId, { title: newTaskTitle });
// delete
await repo(Task).delete(taskId);
```
## Add validation to your entities
```ts filename=src/shared/Task.ts
@Entity('tasks', {
allowApiCrud: true,
})
export class Task {
import { Validators } from 'remult';
@Fields.string({
validate: Validators.required
})
title: string = '';
}
```
## Live Queries
```ts filename=src/shared/Task.ts
repo(Task)
.liveQuery({ where: { completed: true } })
.subscribe((info) => {
tasks = info.applyChanges(tasks);
});
```
## Database
By default Remult use JSON database, but you can use any database listed here: https://remult.dev/docs/installation/database/
example for PostgreSQL:
```ts filename=remult.config.ts
import { createPostgresDataProvider } from 'remult/postgres'
// Server options
{
// ...
entities: [Task],
dataProvider: DATABASE_URL
? createPostgresDataProvider({ connectionString: DATABASE_URL })
: undefined,
// ...
}
```
Documentation
- Remult Documentation: https://remult.dev/docsComprehensive .cursorrules file for Next.js 15 App Router projects with TypeScript, enforcing server components by default, proper use of "use client" directive, and App Router conventions.
Cursor rules for Python FastAPI projects enforcing async patterns, Pydantic v2 models, dependency injection, and proper error handling.
Rules for consistent React component development with TypeScript interfaces, proper hook patterns, and component composition.
Rules optimizing Cursor Agent mode behavior including multi-file editing context, session management, and autonomous task completion patterns.
Cursor rules for projects using Tailwind CSS with shadcn/ui component library, enforcing consistent utility class usage and component patterns.
Rules for Go backend services enforcing idiomatic Go patterns, proper error handling, and clean architecture conventions.