55 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
// Example 4: Creating and working with Groups
 | 
						|
 | 
						|
print("=== Group Example ===\n");
 | 
						|
 | 
						|
// Get a context to work with
 | 
						|
print("1. Getting context...");
 | 
						|
let ctx = get_context(["alice", "bob"]);
 | 
						|
print("   ✓ Context created: " + ctx.context_id());
 | 
						|
 | 
						|
// Create groups with builder pattern
 | 
						|
print("\n2. Creating groups...");
 | 
						|
 | 
						|
let dev_team = new_group()
 | 
						|
    .name("Development Team")
 | 
						|
    .description("Core development team members");
 | 
						|
 | 
						|
print("   ✓ Created group: Development Team");
 | 
						|
 | 
						|
let ops_team = new_group()
 | 
						|
    .name("Operations Team")
 | 
						|
    .description("Infrastructure and operations team");
 | 
						|
 | 
						|
print("   ✓ Created group: Operations Team");
 | 
						|
 | 
						|
let admin_group = new_group()
 | 
						|
    .name("Administrators")
 | 
						|
    .description("System administrators with full access");
 | 
						|
 | 
						|
print("   ✓ Created group: Administrators");
 | 
						|
 | 
						|
// Display group info
 | 
						|
print("\n3. Group information...");
 | 
						|
print("   Dev Team ID: " + dev_team.get_id());
 | 
						|
print("   Dev Team name: " + dev_team.get_name());
 | 
						|
print("   Dev Team description: " + dev_team.get_description());
 | 
						|
 | 
						|
print("   Ops Team ID: " + ops_team.get_id());
 | 
						|
print("   Ops Team name: " + ops_team.get_name());
 | 
						|
 | 
						|
print("   Admin Group ID: " + admin_group.get_id());
 | 
						|
print("   Admin Group name: " + admin_group.get_name());
 | 
						|
 | 
						|
// Save groups to context
 | 
						|
print("\n4. Saving groups to context...");
 | 
						|
let dev_id = ctx.save(dev_team);
 | 
						|
print("   ✓ Saved Development Team with ID: " + dev_id);
 | 
						|
 | 
						|
let ops_id = ctx.save(ops_team);
 | 
						|
print("   ✓ Saved Operations Team with ID: " + ops_id);
 | 
						|
 | 
						|
let admin_id = ctx.save(admin_group);
 | 
						|
print("   ✓ Saved Administrators with ID: " + admin_id);
 | 
						|
 | 
						|
print("\n=== Group Example Complete ===");
 |