Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[drafts] removed old Squirrel example, added new Squerl one

  • Loading branch information...
commit 9c16b38ce31c96757f0867c7357396bdca99f9b9 1 parent 756685b
@masak authored
Showing with 29 additions and 22 deletions.
  1. +29 −0 drafts/squerl-fruits
  2. +0 −22 drafts/squirrel-example
View
29 drafts/squerl-fruits
@@ -0,0 +1,29 @@
+use v6;
+use Squerl;
+
+my $DB = Squerl.sqlite('example.db');
+
+$DB.create_table: 'fruits',
+ 'id' => 'primary_key',
+ 'name' => 'String',
+ 'qty' => 'Int',
+;
+
+my $fruits = $DB<fruits>;
+
+my $i = 0;
+for <apples pears oranges ninjas peaches papayas>
+ Z < 50 20 70 3 15 35> -> $name, $qty {
+
+ $fruits.insert($i++, $name, +$qty);
+}
+
+# those ninjas get in anywhere
+$fruits.filter('name' => 'ninjas').delete;
+
+# new shipment of pears
+$fruits.filter('name' => 'pears').update('qty' => 40);
+
+for $fruits.filter(sql_number('qty').gt(35)).llist {
+ say sprintf 'There are %d %s', .[2], .[1];
+}
View
22 drafts/squirrel-example
@@ -1,22 +0,0 @@
-use Squirrel;
-
-my $DB = Squirrel.sqlite;
-
-$DB.create_table: <items
- primary_key id
- String name
- Float price
->;
-
-given $DB<items> {
- # Populate the table
- .insert: name => 'abc', price => rand() * 100;
- .insert: name => 'def', price => rand() * 100;
- .insert: name => 'ghi', price => rand() * 100;
-
- # Print out the number of records
- say "Item count: {.count}";
-
- # Print out the average price
- say "The average price is: {.avg('price')}";
-}
Please sign in to comment.
Something went wrong with that request. Please try again.