feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
This commit is contained in:
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "dataset" for Dataset
|
||||
|
||||
System.print("=== Dataset Module Demo ===")
|
||||
|
||||
var ds = Dataset.memory()
|
||||
|
||||
System.print("\n--- Insert Records ---")
|
||||
var users = ds["users"]
|
||||
var alice = users.insert({"name": "Alice", "age": 30, "email": "alice@example.com"})
|
||||
System.print("Inserted: %(alice["name"]) with uid: %(alice["uid"])")
|
||||
|
||||
var bob = users.insert({"name": "Bob", "age": 25, "email": "bob@example.com"})
|
||||
var charlie = users.insert({"name": "Charlie", "age": 35, "email": "charlie@example.com"})
|
||||
|
||||
System.print("Total users: %(users.count())")
|
||||
|
||||
System.print("\n--- Query Records ---")
|
||||
var all = users.all()
|
||||
System.print("All users:")
|
||||
for (user in all) {
|
||||
System.print(" - %(user["name"]) (%(user["age"]))")
|
||||
}
|
||||
|
||||
System.print("\nUsers older than 28:")
|
||||
var older = users.find({"age__gt": 28})
|
||||
for (user in older) {
|
||||
System.print(" - %(user["name"])")
|
||||
}
|
||||
|
||||
System.print("\n--- Update Record ---")
|
||||
users.update({"uid": alice["uid"], "age": 31})
|
||||
var updated = users.findOne({"uid": alice["uid"]})
|
||||
System.print("Alice's new age: %(updated["age"])")
|
||||
|
||||
System.print("\n--- Delete Record ---")
|
||||
System.print("Before delete: %(users.count()) users")
|
||||
users.delete(bob["uid"])
|
||||
System.print("After delete: %(users.count()) users")
|
||||
|
||||
System.print("\n--- Auto Schema ---")
|
||||
var products = ds["products"]
|
||||
products.insert({"name": "Widget", "price": 9.99})
|
||||
products.insert({"name": "Gadget", "price": 19.99, "stock": 100})
|
||||
System.print("Product columns: %(products.columns.keys.toList)")
|
||||
|
||||
System.print("\n--- Tables ---")
|
||||
System.print("All tables: %(ds.tables)")
|
||||
|
||||
ds.close()
|
||||
System.print("\nDone.")
|
||||
Reference in New Issue
Block a user