Advanced Concepts Overview
Once you’re comfortable with the basics of datagen models, you can leverage advanced features to achieve more sophisticated and powerful data generation.
What You’ll Learn
Section titled “What You’ll Learn”This section covers advanced topics that will help you:
- Configure and organize models using metadata and custom Go code
- Generate sequential and indexed data with the
itervariable - Create parameterized fields using the
callssection - Build relationships between models using
self.datagenreferences
Topics
Section titled “Topics”Optional Model Sections
Section titled “Optional Model Sections”Learn how to use metadata and misc sections to configure your models and inject custom Go code.
Key features:
- Set default record counts
- Organize models with tags
- Define custom types and constants
- Write helper functions
The iter Variable
Section titled “The iter Variable”Master the built-in iter variable to generate sequential, indexed, and pattern-based data.
Use cases:
- Generate sequential IDs
- Create batches of records
- Implement alternating patterns
- Build index-based logic
Function Calls
Section titled “Function Calls”Understand how to parameterize field generators using the calls section.
Learn about:
- Parameterized field syntax
- Providing arguments in calls
- Argument evaluation and reuse
Model References
Section titled “Model References”Create relationships between models using self and self.datagen references.
Build:
- Same-model references
- Cross-model relationships
- Complex multi-model dependencies
- Realistic foreign key relationships
Nesting models in directories
Section titled “Nesting models in directories”You can nest models in directories to namespace them, according to services for example.
Prerequisites
Section titled “Prerequisites”Before diving into these advanced topics, make sure you understand:
- Data Model basics - Core model structure
- Built-in Functions - Available generator functions
Getting Help
Section titled “Getting Help”If you get stuck, check out:
- Examples - Practical code examples
- Troubleshooting - Common issues and solutions