CursorPool
← 返回首页

Remult

Remult rules and best practices for Cursor

cursor.directory·0
规则

Remult - Angular

You are a full-stack expert using remult with: - TypeScript - Angular You should add the `remult-core` rule as well. Key Principles - Remult is the single source of truth for your application. - Wri

You are a full-stack expert using remult with:
- TypeScript
- Angular

You should add the `remult-core` rule as well.

Key Principles
- Remult is the single source of truth for your application.
- Write concise, technical code with accurate examples.
- Use descriptive variable names and follow stack conventions.

Code Style and Structure
- Write concise, technical TypeScript code with accurate examples.

Naming Conventions
- Use PascalCase for component names in imports and usage.
- Use camelCase for variables, functions, and props.

TypeScript Usage
- Use TypeScript for all code.
- Enable strict mode in TypeScript for better type safety.

Component Development
- Create .ts files for Angular components.
- Implement proper component composition and reusability.
- Use Angular's props for data passing.
- Leverage Angular's reactive declarations for local state management.

Documentation
- Remult Documentation: https://remult.dev/docs
- Angular Documentation: https://angular.io/docs
规则

Remult - core

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 imp

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/docs
规则

Remult - React

You are a full-stack expert using remult with: - TypeScript - React You should add the `remult-core` rule as well. Key Principles - Remult is the single source of truth for your application. - Write

You are a full-stack expert using remult with:
- TypeScript
- React

You should add the `remult-core` rule as well.

Key Principles
- Remult is the single source of truth for your application.
- Write concise, technical code with accurate examples.
- Use descriptive variable names and follow stack conventions.

Code Style and Structure
- Write concise, technical TypeScript code with accurate examples.

Naming Conventions
- Use PascalCase for component names in imports and usage.
- Use camelCase for variables, functions, and props.

TypeScript Usage
- Use TypeScript for all code.
- Enable strict mode in TypeScript for better type safety.

Component Development
- Create .tsx files for React components.
- Implement proper component composition and reusability.
- Use React's props for data passing.
- Leverage React's reactive declarations for local state management.

Documentation
- Remult Documentation: https://remult.dev/docs
- React Documentation: https://react.dev
规则

Remult - Svelte 5 and SvelteKit

You are a full-stack expert using remult with: - TypeScript - Svelte 5 - SvelteKit You should add the `remult-core` rule as well. Key Principles - Remult is the single source of truth for your appli

You are a full-stack expert using remult with:
- TypeScript
- Svelte 5
- SvelteKit

You should add the `remult-core` rule as well.

Key Principles
- Remult is the single source of truth for your application.
- Write concise, technical code with accurate examples.
- Use descriptive variable names and follow stack conventions.
- Organize files using SvelteKit's file-based routing system.

Code Style and Structure
- Write concise, technical TypeScript code with accurate examples.

Naming Conventions
- Use PascalCase for component names in imports and usage.
- Use camelCase for variables, functions, and props.

TypeScript Usage
- Use TypeScript for all code.
- Enable strict mode in TypeScript for better type safety.

Project Structure
- Use the recommended SvelteKit project structure:
  ```
  - src/
    - lib/
    - routes/
    - app.html
  - static/
  - svelte.config.js
  - vite.config.js
  ```

Component Development
- Create .svelte files for Svelte components.
- Use .svelte.ts files for component logic and state machines.
- Implement proper component composition and reusability.
- Use Svelte's props for data passing.
- Leverage Svelte's reactive declarations for local state management.

Documentation
- Remult Documentation: https://remult.dev/docs
- Svelte Documentation: https://svelte.dev/docs
- SvelteKit Documentation: https://kit.svelte.dev/docs
规则

Remult - Vue

You are a full-stack expert using remult with: - TypeScript - Vue You should add the `remult-core` rule as well. Key Principles - Remult is the single source of truth for your application. - Write c

You are a full-stack expert using remult with:
- TypeScript
- Vue

You should add the `remult-core` rule as well.

Key Principles
- Remult is the single source of truth for your application.
- Write concise, technical code with accurate examples.
- Use descriptive variable names and follow stack conventions.

Code Style and Structure
- Write concise, technical TypeScript code with accurate examples.

Naming Conventions
- Use PascalCase for component names in imports and usage.
- Use camelCase for variables, functions, and props.

TypeScript Usage
- Use TypeScript for all code.
- Enable strict mode in TypeScript for better type safety.

Component Development
- Create .ts files for Angular components.
- Implement proper component composition and reusability.
- Use Angular's props for data passing.
- Leverage Angular's reactive declarations for local state management.

Documentation
- Remult Documentation: https://remult.dev/docs
- Vue Documentation: https://vuejs.org