Package Information
Documentation
Kingfoodmart Mongoose - n8n Community Node
๐ Table of Contents
- ๐ฆ Installation
- ๐ Features
- ๐ง Available Nodes
- โ๏ธ Configuration
- ๐ Usage Guide
- ๐ Examples
- ๐ ๏ธ Troubleshooting
- ๐ค Contributing
- ๐ License
๐ฆ Installation
Community Nodes (Recommended)
- Go to Settings > Community Nodes in your n8n instance
- Select Install
- Enter
n8n-nodes-kingfoodmart-vietnam-mongoose-tssas the npm package name - Agree to the risks of using community nodes
- Select Install
Manual Installation
# For n8n installed globally
npm install -g n8n-nodes-kingfoodmart-vietnam-mongoose-tss
# For n8n installed locally
npm install n8n-nodes-kingfoodmart-vietnam-mongoose-tss
๐ Features
Core Capabilities
- โ Full CRUD Operations - Create, Read, Update, Delete with advanced options
- โ Real-time Change Streams - Monitor MongoDB changes instantly
- โ Aggregation Pipeline - Complex data processing and analytics
- โ Schema Validation - Mongoose ODM integration with type conversion
- โ Replica Set Support - High availability and production-ready connections
- โ Connection Management - Automatic connection handling and pooling
- โ Error Handling - Comprehensive error management and debugging
Advanced Features
- ๐ Date Conversion - Automatic string-to-date conversion based on schema
- ๐ Query Optimization - Built-in query performance monitoring
- ๐ฏ Field Selection - Projection support for optimized data transfer
- ๐ Authentication - Support for various MongoDB authentication methods
- ๐ Debug Mode - Detailed logging for development and troubleshooting
- ๐ Production Ready - Optimized for high-performance workflows
๐ง Available Nodes
Kingfoodmart Mongoose (CRUD Operations)
Professional MongoDB operations node with comprehensive CRUD functionality.
Supported Operations:
- Create - Insert new documents with schema validation
- Find - Query multiple documents with filtering, sorting, and pagination
- Find One - Query single document with field selection
- Update/Update One - Modify existing documents with upsert support
- Delete/Delete One - Remove documents with safety checks
- Aggregate - Run complex aggregation pipelines with date conversion
- Count - Count documents matching query criteria
Kingfoodmart Mongoose Change Stream (Real-time Trigger)
Real-time MongoDB Change Stream trigger for monitoring database changes.
Key Features:
- Real-time Monitoring - Instant notifications on data changes
- Multiple Watch Levels - Collection, database, or deployment-wide monitoring
- Operation Filtering - Filter by insert, update, delete, and other operations
- Resume Capability - Continue monitoring from specific points using resume tokens
- Custom Filtering - Advanced match filters and projections
- Multiple Output Formats - Full event, document only, or simplified format
- Count - Count documents matching query criteria
โ๏ธ Configuration
MongoDB Credentials
This package provides a comprehensive MongoDB credential system supporting various connection types and authentication methods.
Connection Types
Single Host Connection
Perfect for development and simple deployments:
Connection String: mongodb://localhost:27017/mydb
Database: myapp (optional override)
Replica Set Connection
Production-ready high availability setup:
Hosts: rs1.example.com:27017,rs2.example.com:27017,rs3.example.com:27017
Username: myuser
Password: mypassword
Replica Set Name: rs0
Auth Source: admin
Database: myapp
Authentication Options
- Auth Source: Database to authenticate against (typically
adminfor replica sets) - SSL/TLS: Secure connections with certificate validation
- Connection Pooling: Optimized connection management
- Timeouts: Configurable connection and socket timeouts
Advanced Connection Options
| Option | Description | Default |
|---|---|---|
| Connection Timeout | Time to establish connection | 10000ms |
| Socket Timeout | Socket operation timeout | 10000ms |
| Max Pool Size | Maximum connections in pool | 10 |
| Min Pool Size | Minimum connections in pool | 0 |
| SSL | Enable secure connections | false |
| SSL Validate | Validate SSL certificates | true |
๐ Usage Guide
Basic CRUD Operations
Create Documents
// Single document
{
"name": "John Doe",
"email": "john@example.com",
"age": 30,
"isActive": true
}
// Multiple documents
[
{"name": "Alice", "email": "alice@example.com"},
{"name": "Bob", "email": "bob@example.com"}
]
Query Documents
// Basic queries
{"isActive": true}
{"age": {"$gte": 18, "$lte": 65}}
{"name": {"$regex": "John", "$options": "i"}}
// Complex queries
{
"isActive": true,
"age": {"$gte": 18},
"status": {"$in": ["active", "premium"]},
"createdAt": {
"$gte": "2024-01-01T00:00:00.000Z",
"$lt": "2024-12-31T23:59:59.999Z"
}
}
Field Selection
// Include specific fields
{"_id": 1, "name": 1, "email": 1, "createdAt": 1}
// Exclude sensitive fields
{"password": 0, "internalNotes": 0}
// Mixed selection
{"_id": 0, "name": 1, "email": 1, "profile.bio": 1}
Aggregation Pipeline
[
{"$match": {"isActive": true}},
{"$group": {
"_id": "$department",
"count": {"$sum": 1},
"avgAge": {"$avg": "$age"}
}},
{"$sort": {"count": -1}},
{"$limit": 10}
]
Real-time Change Monitoring
Basic Change Stream Setup
// Monitor all changes in users collection
Collection: "users"
Watch Level: "Collection"
Operation Types: ["insert", "update", "delete"]
Output Format: "Simplified"
Advanced Change Stream Configuration
// Schema Definition
{
"name": {"type": "String"},
"email": {"type": "String"},
"created_at": {"type": "Date"},
"is_active": {"type": "Boolean"}
}
// Match Filter (only active users)
{
"fullDocument.status": "active",
"operationType": {"$in": ["insert", "update"]}
}
// Projection (reduce data transfer)
{
"fullDocument.name": 1,
"fullDocument.email": 1,
"operationType": 1,
"clusterTime": 1
}
Advanced Features
Date Conversion
Automatic string-to-date conversion based on schema definition:
// Schema with date fields
{
"created_at": {"type": "Date"},
"updated_at": {"type": "Date"},
"birth_date": {"type": "Date"}
}
// Query with string dates (automatically converted)
{
"created_at": {"$gte": "2024-01-01T00:00:00.000Z"}
}
Debug Mode
Enable debug mode in Options for detailed logging:
- Connection status and performance
- Query execution details
- Change stream events
- Error diagnostics
๐ Examples
E-commerce Order Processing
// Monitor new orders in real-time
Collection: "orders"
Operation Types: ["insert"]
Match Filter: {"fullDocument.status": "pending"}
Output Format: "Document"
// Update order status
Operation: "updateOne"
Query: {"_id": "{{$json.orderId}}"}
Update Data: {"status": "processing", "updated_at": "{{$now}}"}
User Activity Tracking
// Track user login events
Collection: "user_sessions"
Operation Types: ["insert", "update"]
Match Filter: {"fullDocument.event_type": "login"}
// Aggregate user activity
Pipeline: [
{"$match": {"event_type": "login"}},
{"$group": {"_id": "$user_id", "login_count": {"$sum": 1}}},
{"$sort": {"login_count": -1}}
]
Data Synchronization
// Sync changes to external system
Collection: "products"
Operation Types: ["insert", "update", "delete"]
Resume Token: "{{$json.last_resume_token}}"
Output Format: "Full"
๐ ๏ธ Troubleshooting
Common Issues
Connection Problems
# Error: "Failed to connect to MongoDB"
โ
Check connection string format
โ
Verify MongoDB server is running
โ
Check network connectivity and firewall
โ
Validate authentication credentials
Change Stream Issues
# Error: "Change stream failed to initialize"
โ
Ensure MongoDB 3.6+ with replica set
โ
Check user permissions for change streams
โ
Verify collection exists
โ
Review match filter syntax
Performance Issues
# Slow query performance
โ
Add appropriate indexes
โ
Use projection to limit fields
โ
Optimize match filters
โ
Enable debug mode for analysis
Debug Mode
Enable debug mode in node options for detailed logging:
- Connection diagnostics
- Query execution plans
- Change stream events
- Performance metrics
- Error stack traces
Best Practices
Production Deployment
- โ Use replica sets for high availability
- โ Configure appropriate connection pooling
- โ Set up proper authentication and SSL
- โ Monitor connection and query performance
- โ Implement proper error handling in workflows
Performance Optimization
- โ Use indexes for frequently queried fields
- โ Limit result sets with projection
- โ Use aggregation for complex operations
- โ Monitor and optimize slow queries
- โ Configure appropriate batch sizes for change streams
Security
- โ Use strong authentication credentials
- โ Enable SSL/TLS for production
- โ Limit database user permissions
- โ Regularly rotate credentials
- โ Monitor access logs
๐ Contact & Support
For technical support, questions, or collaboration:
๐ง Email: hoanh.nguyen@kingfoodmart.com
๐ License
This project is licensed under the MIT License - see the LICENSE.md file for details.
โญ If this package helps your workflow, please consider giving it a star on npm!
Made with โค๏ธ by Kingfoodmart Vietnam
ยฉ 2024 Kingfoodmart. All rights reserved.