fix: Fix the examples
- Updated the examples to match the new fix of the heromodels - Removed the caller variable of the set method since the method does not return a value now
This commit is contained in:
6
examples/hero/heromodels/heromodels_calendar_event.vsh
Normal file → Executable file
6
examples/hero/heromodels/heromodels_calendar_event.vsh
Normal file → Executable file
@@ -31,10 +31,10 @@ o.tags = mydb.calendar_event.db.tags_get(['work', 'meeting', 'team'])!
|
||||
// Add comments if needed
|
||||
// o.comments = mydb.calendar_event.db.comments_get([CommentArg{comment: 'This is a comment'}])!
|
||||
|
||||
oid := mydb.calendar_event.set(o)!
|
||||
mut o2 := mydb.calendar_event.get(oid)!
|
||||
mydb.calendar_event.set(mut o)!
|
||||
mut o2 := mydb.calendar_event.get(o.id)!
|
||||
|
||||
println('Calendar Event ID: ${oid}')
|
||||
println('Calendar Event ID: ${o.id}')
|
||||
println('Calendar Event object: ${o2}')
|
||||
|
||||
mut objects := mydb.calendar_event.list()!
|
||||
|
||||
6
examples/hero/heromodels/heromodels_calendar_event_with_recurrence.vsh
Normal file → Executable file
6
examples/hero/heromodels/heromodels_calendar_event_with_recurrence.vsh
Normal file → Executable file
@@ -41,10 +41,10 @@ o.tags = mydb.calendar_event.db.tags_get(['work', 'meeting', 'team'])!
|
||||
// Add comments if needed
|
||||
// o.comments = mydb.calendar_event.db.comments_get([CommentArg{comment: 'This is a comment'}])!
|
||||
|
||||
oid := mydb.calendar_event.set(o)!
|
||||
mut o2 := mydb.calendar_event.get(oid)!
|
||||
mydb.calendar_event.set(mut o)!
|
||||
mut o2 := mydb.calendar_event.get(o.id)!
|
||||
|
||||
println('Calendar Event ID: ${oid}')
|
||||
println('Calendar Event ID: ${o.id}')
|
||||
println('Calendar Event object: ${o2}')
|
||||
|
||||
mut objects := mydb.calendar_event.list()!
|
||||
|
||||
10
examples/hero/heromodels/heromodels_chat_group.vsh
Normal file → Executable file
10
examples/hero/heromodels/heromodels_chat_group.vsh
Normal file → Executable file
@@ -15,11 +15,11 @@ mut chat_group := mydb.chat_group.new(
|
||||
)!
|
||||
|
||||
// Save to database
|
||||
oid := mydb.chat_group.set(chat_group)!
|
||||
println('Created chat group with ID: ${oid}')
|
||||
mydb.chat_group.set(mut chat_group)!
|
||||
println('Created chat group with ID: ${chat_group.id}')
|
||||
|
||||
// Retrieve from database
|
||||
mut chat_group2 := mydb.chat_group.get(oid)!
|
||||
mut chat_group2 := mydb.chat_group.get(chat_group.id)!
|
||||
println('Retrieved chat group: ${chat_group2}')
|
||||
|
||||
// List all chat groups
|
||||
@@ -29,8 +29,8 @@ println('All chat groups: ${chat_groups}')
|
||||
// Update the chat group
|
||||
chat_group2.is_archived = true
|
||||
chat_group2.last_activity = 1672531200
|
||||
mydb.chat_group.set(chat_group2)!
|
||||
mydb.chat_group.set(mut chat_group2)!
|
||||
|
||||
// Retrieve updated chat group
|
||||
mut chat_group3 := mydb.chat_group.get(oid)!
|
||||
mut chat_group3 := mydb.chat_group.get(chat_group2.id)!
|
||||
println('Updated chat group: ${chat_group3}')
|
||||
|
||||
15
examples/hero/heromodels/heromodels_chat_message.vsh
Normal file → Executable file
15
examples/hero/heromodels/heromodels_chat_message.vsh
Normal file → Executable file
@@ -13,14 +13,15 @@ mut chat_group := mydb.chat_group.new(
|
||||
last_activity: 0
|
||||
is_archived: false
|
||||
)!
|
||||
chat_group_id := mydb.chat_group.set(chat_group)!
|
||||
|
||||
mydb.chat_group.set(mut chat_group)!
|
||||
|
||||
// Create a new chat message
|
||||
mut chat_message := mydb.chat_message.new(
|
||||
name: 'Hello World Message'
|
||||
description: 'A simple hello world message'
|
||||
content: 'Hello, world!'
|
||||
chat_group_id: chat_group_id
|
||||
chat_group_id: chat_group.id
|
||||
sender_id: 1
|
||||
parent_messages: []
|
||||
fs_files: []
|
||||
@@ -31,11 +32,11 @@ mut chat_message := mydb.chat_message.new(
|
||||
)!
|
||||
|
||||
// Save to database
|
||||
oid := mydb.chat_message.set(chat_message)!
|
||||
println('Created chat message with ID: ${oid}')
|
||||
mydb.chat_message.set(mut chat_message)!
|
||||
println('Created chat message with ID: ${chat_message.id}')
|
||||
|
||||
// Retrieve from database
|
||||
mut chat_message2 := mydb.chat_message.get(oid)!
|
||||
mut chat_message2 := mydb.chat_message.get(chat_message.id)!
|
||||
println('Retrieved chat message: ${chat_message2}')
|
||||
|
||||
// List all chat messages
|
||||
@@ -44,8 +45,8 @@ println('All chat messages: ${chat_messages}')
|
||||
|
||||
// Update the chat message
|
||||
chat_message2.status = .read
|
||||
mydb.chat_message.set(chat_message2)!
|
||||
mydb.chat_message.set(mut chat_message2)!
|
||||
|
||||
// Retrieve updated chat message
|
||||
mut chat_message3 := mydb.chat_message.get(oid)!
|
||||
mut chat_message3 := mydb.chat_message.get(chat_message.id)!
|
||||
println('Updated chat message: ${chat_message3}')
|
||||
|
||||
14
examples/hero/heromodels/heromodels_group.vsh
Normal file → Executable file
14
examples/hero/heromodels/heromodels_group.vsh
Normal file → Executable file
@@ -18,15 +18,15 @@ mut o := mydb.group.new(
|
||||
o.tags = mydb.group.db.tags_get(['team', 'development'])!
|
||||
|
||||
// Save to database
|
||||
oid := mydb.group.set(o)!
|
||||
println('Created Group ID: ${oid}')
|
||||
mydb.group.set(mut o)!
|
||||
println('Created Group ID: ${o.id}')
|
||||
|
||||
// Check if the group exists
|
||||
mut exists := mydb.group.exist(oid)!
|
||||
mut exists := mydb.group.exist(o.id)!
|
||||
println('Group exists: ${exists}')
|
||||
|
||||
// Retrieve from database
|
||||
mut o2 := mydb.group.get(oid)!
|
||||
mut o2 := mydb.group.get(o.id)!
|
||||
println('Retrieved Group object: ${o2}')
|
||||
|
||||
// List all groups
|
||||
@@ -34,9 +34,9 @@ mut objects := mydb.group.list()!
|
||||
println('All groups: ${objects}')
|
||||
|
||||
// Delete the group
|
||||
mydb.group.delete(oid)!
|
||||
println('Deleted group with ID: ${oid}')
|
||||
mydb.group.delete(o.id)!
|
||||
println('Deleted group with ID: ${o.id}')
|
||||
|
||||
// Check if the group still exists
|
||||
exists = mydb.group.exist(oid)!
|
||||
exists = mydb.group.exist(o.id)!
|
||||
println('Group exists after deletion: ${exists}')
|
||||
|
||||
6
examples/hero/heromodels/heromodels_group_add_members.vsh
Normal file → Executable file
6
examples/hero/heromodels/heromodels_group_add_members.vsh
Normal file → Executable file
@@ -23,11 +23,11 @@ o.add_member(3, heromodels.GroupRole.reader)
|
||||
o.tags = mydb.group.db.tags_get(['team', 'marketing'])!
|
||||
|
||||
// Save to database
|
||||
oid := mydb.group.set(o)!
|
||||
println('Created Group ID: ${oid}')
|
||||
mydb.group.set(mut o)!
|
||||
println('Created Group ID: ${o.id}')
|
||||
|
||||
// Retrieve from database
|
||||
mut o2 := mydb.group.get(oid)!
|
||||
mut o2 := mydb.group.get(o.id)!
|
||||
println('Retrieved Group object: ${o2}')
|
||||
|
||||
// Check the number of members
|
||||
|
||||
20
examples/hero/heromodels/heromodels_group_relationships.vsh
Normal file → Executable file
20
examples/hero/heromodels/heromodels_group_relationships.vsh
Normal file → Executable file
@@ -14,8 +14,8 @@ mut parent_group := mydb.group.new(
|
||||
parent_group: 0
|
||||
)!
|
||||
|
||||
parent_oid := mydb.group.set(parent_group)!
|
||||
println('Created Parent Group ID: ${parent_oid}')
|
||||
mydb.group.set(mut parent_group)!
|
||||
println('Created Parent Group ID: ${parent_group.id}')
|
||||
|
||||
// Create a subgroup
|
||||
mut subgroup := mydb.group.new(
|
||||
@@ -24,20 +24,20 @@ mut subgroup := mydb.group.new(
|
||||
is_public: false
|
||||
members: []
|
||||
subgroups: []
|
||||
parent_group: parent_oid
|
||||
parent_group: parent_group.id
|
||||
)!
|
||||
|
||||
sub_oid := mydb.group.set(subgroup)!
|
||||
println('Created Subgroup ID: ${sub_oid}')
|
||||
mydb.group.set(mut subgroup)!
|
||||
println('Created Subgroup ID: ${subgroup.id}')
|
||||
|
||||
// Update the parent group to include the subgroup
|
||||
mut updated_parent := mydb.group.get(parent_oid)!
|
||||
updated_parent.subgroups = [sub_oid]
|
||||
mydb.group.set(updated_parent)!
|
||||
mut updated_parent := mydb.group.get(parent_group.id)!
|
||||
updated_parent.subgroups = [subgroup.id]
|
||||
mydb.group.set(mut updated_parent)!
|
||||
|
||||
// Retrieve both groups to verify relationships
|
||||
mut parent_from_db := mydb.group.get(parent_oid)!
|
||||
mut sub_from_db := mydb.group.get(sub_oid)!
|
||||
mut parent_from_db := mydb.group.get(parent_group.id)!
|
||||
mut sub_from_db := mydb.group.get(subgroup.id)!
|
||||
|
||||
println('Parent Group: ${parent_from_db}')
|
||||
println('Subgroup: ${sub_from_db}')
|
||||
|
||||
8
examples/hero/heromodels/heromodels_group_with_members.vsh
Normal file → Executable file
8
examples/hero/heromodels/heromodels_group_with_members.vsh
Normal file → Executable file
@@ -29,15 +29,15 @@ mut o := mydb.group.new(
|
||||
o.tags = mydb.group.db.tags_get(['team', 'development'])!
|
||||
|
||||
// Save to database
|
||||
oid := mydb.group.set(o)!
|
||||
println('Created Group ID: ${oid}')
|
||||
mydb.group.set(mut o)!
|
||||
println('Created Group ID: ${o.id}')
|
||||
|
||||
// Check if the group exists
|
||||
mut exists := mydb.group.exist(oid)!
|
||||
mut exists := mydb.group.exist(o.id)!
|
||||
println('Group exists: ${exists}')
|
||||
|
||||
// Retrieve from database
|
||||
mut o2 := mydb.group.get(oid)!
|
||||
mut o2 := mydb.group.get(o.id)!
|
||||
println('Retrieved Group object: ${o2}')
|
||||
|
||||
// List all groups
|
||||
|
||||
14
examples/hero/heromodels/heromodels_project.vsh
Normal file → Executable file
14
examples/hero/heromodels/heromodels_project.vsh
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl,enable_globals -no-skip-unused run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals -no-skip-unused run
|
||||
|
||||
import freeflowuniverse.herolib.hero.heromodels
|
||||
import freeflowuniverse.herolib.hero.db
|
||||
@@ -66,11 +66,11 @@ mut project := mydb.project.new(
|
||||
)!
|
||||
|
||||
// Save the project to the database
|
||||
project_id := mydb.project.set(project)!
|
||||
println('Created project with ID: ${project_id}')
|
||||
mydb.project.set(mut project)!
|
||||
println('Created project with ID: ${project.id}')
|
||||
|
||||
// Retrieve the project from the database
|
||||
mut retrieved_project := mydb.project.get(project_id)!
|
||||
mut retrieved_project := mydb.project.get(project.id)!
|
||||
println('Retrieved project: ${retrieved_project}')
|
||||
|
||||
// List all projects
|
||||
@@ -78,13 +78,13 @@ mut all_projects := mydb.project.list()!
|
||||
println('All projects: ${all_projects}')
|
||||
|
||||
// Check if the project exists
|
||||
exists := mydb.project.exist(project_id)!
|
||||
mut exists := mydb.project.exist(project.id)!
|
||||
println('Project exists: ${exists}')
|
||||
|
||||
// Delete the project
|
||||
mydb.project.delete(project_id)!
|
||||
mydb.project.delete(project.id)!
|
||||
println('Project deleted')
|
||||
|
||||
// Check if the project still exists
|
||||
exists = mydb.project.exist(project_id)!
|
||||
exists = mydb.project.exist(project.id)!
|
||||
println('Project exists after deletion: ${exists}')
|
||||
|
||||
55
examples/hero/heromodels/heromodels_project_issue.vsh
Normal file → Executable file
55
examples/hero/heromodels/heromodels_project_issue.vsh
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl,enable_globals -no-skip-unused run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals -no-skip-unused run
|
||||
|
||||
import freeflowuniverse.herolib.hero.heromodels
|
||||
import freeflowuniverse.herolib.hero.db
|
||||
@@ -6,12 +6,51 @@ import freeflowuniverse.herolib.hero.db
|
||||
mut mydb := heromodels.new()!
|
||||
mydb.project_issue.db.redis.flushdb()!
|
||||
|
||||
// Create swimlanes
|
||||
swimlane := heromodels.Swimlane{
|
||||
name: 'todo'
|
||||
description: 'Tasks to be done'
|
||||
order: 1
|
||||
color: '#FF0000'
|
||||
is_done: false
|
||||
}
|
||||
|
||||
// Create milestones
|
||||
milestone := heromodels.Milestone{
|
||||
name: 'phase_1'
|
||||
description: 'First development phase'
|
||||
due_date: 1672531200 // 2023-01-01
|
||||
completed: false
|
||||
issues: [u32(1), u32(2)]
|
||||
}
|
||||
|
||||
// Create a new project
|
||||
mut project := mydb.project.new(
|
||||
name: 'Sample Project'
|
||||
description: 'A sample project for demonstration'
|
||||
swimlanes: [swimlane]
|
||||
milestones: [milestone]
|
||||
issues: ['issue1', 'issue2', 'issue3']
|
||||
fs_files: [u32(100), u32(200)]
|
||||
status: .active
|
||||
start_date: '2023-01-01'
|
||||
end_date: '2023-12-31'
|
||||
tags: ['sample', 'demo', 'project']
|
||||
comments: [db.CommentArg{
|
||||
comment: 'This is a sample project'
|
||||
}]
|
||||
)!
|
||||
|
||||
// Save the project to the database
|
||||
mydb.project.set(mut project)!
|
||||
println('Created project with ID: ${project.id}')
|
||||
|
||||
// Create a new project issue
|
||||
mut issue := mydb.project_issue.new(
|
||||
name: 'Fix login bug'
|
||||
description: 'Users are unable to login with their credentials'
|
||||
title: 'Login functionality is broken'
|
||||
project_id: u32(1)
|
||||
project_id: project.id
|
||||
issue_type: .bug
|
||||
priority: .high
|
||||
status: .open
|
||||
@@ -36,11 +75,11 @@ mut issue := mydb.project_issue.new(
|
||||
)!
|
||||
|
||||
// Save the issue to the database
|
||||
issue_id := mydb.project_issue.set(issue)!
|
||||
println('Created project issue with ID: ${issue_id}')
|
||||
mydb.project_issue.set(mut issue)!
|
||||
println('Created project issue with ID: ${issue.id}')
|
||||
|
||||
// Retrieve the issue from the database
|
||||
mut retrieved_issue := mydb.project_issue.get(issue_id)!
|
||||
mut retrieved_issue := mydb.project_issue.get(issue.id)!
|
||||
println('Retrieved project issue: ${retrieved_issue}')
|
||||
|
||||
// List all project issues
|
||||
@@ -48,13 +87,13 @@ mut all_issues := mydb.project_issue.list()!
|
||||
println('All project issues: ${all_issues}')
|
||||
|
||||
// Check if the issue exists
|
||||
exists := mydb.project_issue.exist(issue_id)!
|
||||
mut exists := mydb.project_issue.exist(issue.id)!
|
||||
println('Project issue exists: ${exists}')
|
||||
|
||||
// Delete the issue
|
||||
mydb.project_issue.delete(issue_id)!
|
||||
mydb.project_issue.delete(issue.id)!
|
||||
println('Project issue deleted')
|
||||
|
||||
// Check if the issue still exists
|
||||
exists = mydb.project_issue.exist(issue_id)!
|
||||
exists = mydb.project_issue.exist(issue.id)!
|
||||
println('Project issue exists after deletion: ${exists}')
|
||||
|
||||
14
examples/hero/heromodels/heromodels_user.vsh
Normal file → Executable file
14
examples/hero/heromodels/heromodels_user.vsh
Normal file → Executable file
@@ -22,15 +22,15 @@ mut o := mydb.user.new(
|
||||
)!
|
||||
|
||||
// Save to database
|
||||
oid := mydb.user.set(o)!
|
||||
println('Created User ID: ${oid}')
|
||||
mydb.user.set(mut o)!
|
||||
println('Created User ID: ${o.id}')
|
||||
|
||||
// Check if the user exists
|
||||
mut exists := mydb.user.exist(oid)!
|
||||
mut exists := mydb.user.exist(o.id)!
|
||||
println('User exists: ${exists}')
|
||||
|
||||
// Retrieve from database
|
||||
mut o2 := mydb.user.get(oid)!
|
||||
mut o2 := mydb.user.get(o.id)!
|
||||
println('Retrieved User object: ${o2}')
|
||||
|
||||
// List all users
|
||||
@@ -38,9 +38,9 @@ mut objects := mydb.user.list()!
|
||||
println('All users: ${objects}')
|
||||
|
||||
// Delete the user
|
||||
mydb.user.delete(oid)!
|
||||
println('Deleted user with ID: ${oid}')
|
||||
mydb.user.delete(o.id)!
|
||||
println('Deleted user with ID: ${o.id}')
|
||||
|
||||
// Check if the user still exists
|
||||
exists = mydb.user.exist(oid)!
|
||||
exists = mydb.user.exist(o.id)!
|
||||
println('User exists after deletion: ${exists}')
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals -no-skip-unused run
|
||||
|
||||
import json
|
||||
import freeflowuniverse.herolib.hero.heromodels.openrpc
|
||||
import freeflowuniverse.herolib.hero.heromodels.rpc
|
||||
import freeflowuniverse.herolib.schemas.jsonrpc
|
||||
import freeflowuniverse.herolib.hero.heromodels
|
||||
|
||||
fn main() {
|
||||
mut handler := openrpc.new_heromodels_handler()!
|
||||
mut handler := rpc.new()!
|
||||
|
||||
my_calendar := heromodels.calendar_new(
|
||||
name: 'My Calendar'
|
||||
|
||||
Reference in New Issue
Block a user