Hello Front,
Thanks for your question. I've put together a very simple example schema (attached to this forum posting) that should allow you to see how this is achieved. Download both the ProductExampleSchema.scm and ProductExampleSchema.ddb files and together load them in to the JADE system you're using. They'll create a new schema called "ProductExampleSchema".
There are two JadeScript methods within the schema; createTestData() and getData(). The latter of which is shown below:
Code: Select all
getData() protected;
vars
root : Root;
product : Product;
brand : Brand;
begin
// Setup the Root object so we can access it's local collection
// of Brands...
root := Root.firstInstance;
if root = null then
write "Error: Root object is null, aborting.";
return;
endif;
// Iterate each Brand object and then each Product within that
// Brand's collection of Products...
foreach brand in root.allBrands do
foreach product in brand.allProducts do
// Display the Product information...
write "Name: " & product.name;
write "Price: $" & product.price.String;
write "Weight: " & product.weight.String & "g";
write "Brand Name: " & brand.name;
write "Brand Trademark: " & brand.trademark;
write "Brand Grade: " & brand.grade.String;
write Cr;
endforeach;
endforeach;
end;
If you first execute createTestData(), then getData() the following information will be output:
Name: Sliced Peaches
Price: $2.99
Weight: 300g
Brand Name: Store Brand
Brand Trademark: Store Brand Limited
Brand Grade: C
Name: Sliced Peaches
Price: $3.69
Weight: 300g
Brand Name: Watties
Brand Trademark: Watties Limited
Brand Grade: A
It's a very simple example but should show you how to store and retrieve persistent data in a JADE database using MemberKeyDictionary collections and a singleton 'Root' object.
Regards,