Salesforce ORM Documentation¶
⚠️ DEPRECATION NOTICE: The string-based
Modelclass andQueryBuilderare deprecated and will be removed in v2.0.0. Please migrate toLambdaModel. See Migration Guide.
Welcome to the Salesforce ORM documentation! This library provides a type-safe, lambda-based query interface for Salesforce with full closure variable support.
Quick Links¶
Getting Started¶
New to the library? Start here:
- Installation & Configuration - Install and configure the library
- Quick Start Guide - Your first query in 5 minutes
- Configuration Options - Detailed configuration
Models¶
Learn how to define and generate models:
- Defining Models - Create model classes manually
- Model Generation (CLI) - Auto-generate from Salesforce metadata
- Field Types - TypeScript types and custom fields
Querying¶
Master the query API:
- Lambda Queries (Recommended) - Type-safe queries with closures
- Basic Queries - SELECT, WHERE, ORDER BY
- Advanced Queries - Complex conditions and grouping
- Pagination - Limit, offset, and paginate()
- Relationships & Subqueries - Eager/lazy loading
CRUD Operations¶
Work with Salesforce records:
- Creating Records - create() and save()
- Reading Records - find(), first(), get()
- Updating Records - update() and save()
- Deleting Records - delete() and destroy()
Advanced Topics¶
Deep dive into advanced features:
- Lifecycle Hooks (Observers) - React to model events
- Closure Variables Deep Dive - How closures work
- Error Handling - Try/catch and validation
- Salesforce Governor Limits - Best practices
CLI Tools¶
Command-line utilities:
- CLI Commands Reference - All available commands
- Authentication Setup - JWT bearer flow
- Scaffolding Guide - Generate models from metadata
Reference¶
- API Reference - Method signatures
- Migration Guide - Migrate from string-based queries
- Examples - Common patterns and recipes
Key Features¶
Type-Safe Lambda Queries¶
const accounts = await Account
.select(x => ({
Id: x.Id, // ✓ IntelliSense
Name: x.Name // ✓ Type-checked
}))
.limit(10)
.get();
Closure Variables¶
const industry = 'Technology';
const accounts = await Account
.select(x => ({ Id: x.Id, Name: x.Name }))
.where(x => x.Industry === industry) // ✓ Closures work!
.get();
Relationship Queries¶
const activeStatus = true;
const accounts = await Account
.select(x => ({
Name: x.Name,
Contacts: x.Contacts
.select(c => ({ Name: c.Name }))
.where(c => c.Active__c === activeStatus) // ✓ Closures in subqueries!
}))
.get();
Important Notes¶
⚠️ Governor Limits: This library does NOT automatically handle Salesforce governor limits. Always use .limit() and proper filtering.
⚠️ Observers: Observers are JavaScript/TypeScript hooks that run in your application, NOT Salesforce Triggers, Process Builder, or Flows.