Last active
December 19, 2015 22:59
Revisions
-
dkubb revised this gist
Jul 27, 2013 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,35 +5,35 @@ orders: Axiom::Relation.new([[:id, Integer], [:customer_id, Integer]]) ) # Insert customer data customers = adapter[:customers] customers.insert([[1, 'Dan Kubb']]) customers.insert([[2, 'John Doe']]) # Insert order data orders = adapter[:orders] orders.insert([[1, 1]]) orders.insert([[2, 1]]) orders.insert([[3, 1]]) orders.insert([[4, 2]]) # Join customers and orders customer_orders = customers. rename(id: :customer_id). join(orders.rename(id: :order_id)) # Demonstrate writable view-like behaviour # Insert into the join customer_orders.insert([[3, 'Jane Doe', 5]]) # Inserts are propagated to the base relations customers.count # => 3 orders.count # => 5 # Delete from a join customer_orders.delete([[3, 'Jane Doe', 5]]) # Deletes are propagated to the base relations customers.count # => 2 orders.count # => 4 -
dkubb revised this gist
Jul 27, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,12 +6,12 @@ ) # insert customer data customers = adapter[:customers] customers.insert([[1, 'Dan Kubb']]) customers.insert([[2, 'John Doe']]) # insert order data orders = adapter[:orders] orders.insert([[1, 1]]) orders.insert([[2, 1]]) orders.insert([[3, 1]]) -
dkubb revised this gist
Jul 27, 2013 . 1 changed file with 3 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,8 @@ require 'axiom-memory-adapter' adapter = Axiom::Adapter::Memory.new( customers: Axiom::Relation.new([[:id, Integer], [:name, String]]), orders: Axiom::Relation.new([[:id, Integer], [:customer_id, Integer]]) ) # insert customer data -
dkubb revised this gist
Jul 27, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,12 +34,12 @@ customer_orders.insert([[3, 'Jane Doe', 5]]) # inserts are propagated to the base relations customers.count # => 3 orders.count # => 5 # delete from a join customer_orders.delete([[3, 'Jane Doe', 5]]) # deletes are propagated to the base relations customers.count # => 2 orders.count # => 4 -
dkubb revised this gist
Jul 27, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,11 +3,11 @@ adapter = Axiom::Adapter::Memory.new # setup base relations adapter['customers'] = Axiom::Relation.new( [[:id, Integer], [:name, String]] ) adapter['orders'] = Axiom::Relation.new( [[:id, Integer], [:customer_id, Integer]] ) -
dkubb revised this gist
Jul 27, 2013 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,15 +13,15 @@ # insert customer data customers = adapter['customers'] customers.insert([[1, 'Dan Kubb']]) customers.insert([[2, 'John Doe']]) # insert order data orders = adapter['orders'] orders.insert([[1, 1]]) orders.insert([[2, 1]]) orders.insert([[3, 1]]) orders.insert([[4, 2]]) # join customers and orders customer_orders = customers. @@ -31,7 +31,7 @@ # demonstrate writable view-like behaviour # insert into the join customer_orders.insert([[3, 'Jane Doe', 5]]) # inserts are propagated to the base relations adapter['customers'].count # => 3 -
dkubb revised this gist
Jul 19, 2013 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ adapter = Axiom::Adapter::Memory.new # setup base relations adapter['customers'] = Axiom::Relation::Empty.new( [[:id, Integer], [:name, String]] ) @@ -10,21 +11,26 @@ [[:id, Integer], [:customer_id, Integer]] ) # insert customer data customers = adapter['customers'] customers = customers.insert([[1, 'Dan Kubb']]) customers = customers.insert([[2, 'John Doe']]) # insert order data orders = adapter['orders'] orders = orders.insert([[1, 1]]) orders = orders.insert([[2, 1]]) orders = orders.insert([[3, 1]]) orders = orders.insert([[4, 2]]) # join customers and orders customer_orders = customers. rename(id: :customer_id). join(orders.rename(id: :order_id)) # demonstrate writable view-like behaviour # insert into the join customer_orders = customer_orders.insert([[3, 'Jane Doe', 5]]) # inserts are propagated to the base relations -
dkubb created this gist
Jul 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ require 'axiom-memory-adapter' adapter = Axiom::Adapter::Memory.new adapter['customers'] = Axiom::Relation::Empty.new( [[:id, Integer], [:name, String]] ) adapter['orders'] = Axiom::Relation::Empty.new( [[:id, Integer], [:customer_id, Integer]] ) customers = adapter['customers'] customers = customers.insert([[1, 'Dan Kubb']]) customers = customers.insert([[2, 'John Doe']]) orders = adapter['orders'] orders = orders.insert([[1, 1]]) orders = orders.insert([[2, 1]]) orders = orders.insert([[3, 1]]) orders = orders.insert([[4, 2]]) customer_orders = customers. rename(id: :customer_id). join(orders.rename(id: :order_id)) # insert into a join customer_orders = customer_orders.insert([[3, 'Jane Doe', 5]]) # inserts are propagated to the base relations adapter['customers'].count # => 3 adapter['orders'].count # => 5 # delete from a join customer_orders.delete([[3, 'Jane Doe', 5]]) # deletes are propagated to the base relations adapter['customers'].count # => 2 adapter['orders'].count # => 4