wip
This commit is contained in:
54
examples/engine/03_user.rhai
Normal file
54
examples/engine/03_user.rhai
Normal file
@@ -0,0 +1,54 @@
|
||||
// Example 3: Creating and working with Users
|
||||
|
||||
print("=== User 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 users with builder pattern
|
||||
print("\n2. Creating users...");
|
||||
|
||||
let alice = new_user()
|
||||
.username("alice")
|
||||
.add_email("alice@example.com");
|
||||
|
||||
print(" ✓ Created user: alice");
|
||||
|
||||
let bob = new_user()
|
||||
.username("bob")
|
||||
.add_email("bob@example.com");
|
||||
|
||||
print(" ✓ Created user: bob");
|
||||
|
||||
let charlie = new_user()
|
||||
.username("charlie")
|
||||
.add_email("charlie@example.com");
|
||||
|
||||
print(" ✓ Created user: charlie");
|
||||
|
||||
// Display user info
|
||||
print("\n3. User information...");
|
||||
print(" Alice ID: " + alice.get_id());
|
||||
print(" Alice username: " + alice.get_username());
|
||||
print(" Alice email: " + alice.get_email());
|
||||
|
||||
print(" Bob ID: " + bob.get_id());
|
||||
print(" Bob username: " + bob.get_username());
|
||||
|
||||
print(" Charlie ID: " + charlie.get_id());
|
||||
print(" Charlie username: " + charlie.get_username());
|
||||
|
||||
// Save users to context
|
||||
print("\n4. Saving users to context...");
|
||||
let alice_id = ctx.save(alice);
|
||||
print(" ✓ Saved alice with ID: " + alice_id);
|
||||
|
||||
let bob_id = ctx.save(bob);
|
||||
print(" ✓ Saved bob with ID: " + bob_id);
|
||||
|
||||
let charlie_id = ctx.save(charlie);
|
||||
print(" ✓ Saved charlie with ID: " + charlie_id);
|
||||
|
||||
print("\n=== User Example Complete ===");
|
||||
Reference in New Issue
Block a user