JavaScript SDK
Complete guide to using Cocobase with JavaScript and TypeScript applications.Installation
npm:Quick Start
Initialize Cocobase
Basic Operations
Querying Data
Simple Filters
Query Builder
Operators Reference
Comparison Operators
| Operator | Filter Key | Example |
|---|---|---|
| Equal | field | { status: "active" } |
| Greater Than | field__gt | { age__gt: 18 } |
| Greater or Equal | field__gte | { age__gte: 18 } |
| Less Than | field__lt | { age__lt: 65 } |
| Less or Equal | field__lte | { age__lte: 65 } |
| Not Equal | field__ne | { status__ne: "deleted" } |
String Operators
| Operator | Filter Key | Example |
|---|---|---|
| Contains | field__contains | { title__contains: "javascript" } |
| Starts With | field__startswith | { email__startswith: "admin" } |
| Ends With | field__endswith | { domain__endswith: ".com" } |
Array Operators
| Operator | Filter Key | Example |
|---|---|---|
| In Array | field__in | { status__in: "active,pending" } |
| Not In Array | field__notin | { status__notin: "deleted,archived" } |
Sorting and Pagination
Sorting
Pagination
Type Safety with TypeScript
Define Your Types
Create Typed Documents
Authentication
Email/Password
OAuth
Real-time Data
Watch Collection
Watch Document
File Storage
Upload Files
Download Files
Error Handling
Best Practices
1. Always Use Types
2. Always Set Limits
3. Handle Errors
4. Use Environment Variables
Next Steps
- Flutter SDK - Learn about the Flutter SDK
- Authentication - Deep dive into auth
- Querying - Advanced query techniques
- Real-time - Real-time data synchronization
