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 characters
| require Exquisite | |
| require Amnesia | |
| use Amnesia | |
| defdatabase DB do | |
| deftable M,[:id,:foo],type: :ordered_set do | |
| end | |
| end | |
| defmodule A do | |
| defmacro get_by_key(module,key,val) do | |
| quote do |
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 characters
| defmodule DBTM do | |
| defmacro get_by_key(module,key,value) do | |
| quote do | |
| s = Exquisite.match unquote(module), | |
| where: unquote(key) == unquote(value) | |
| Amnesia.transaction do | |
| res = Amnesia.Table.select(unquote(module),s) | |
| case Amnesia.Table.select(unquote(module),s) do | |
| nil -> [] | |
| res -> res.values |
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 characters
| require Exquisite | |
| require Amnesia | |
| use Amnesia | |
| defdatabase DB do | |
| deftable M,[:id,:foo],type: :ordered_set do | |
| end | |
| end | |
| defmodule A do | |
| defmacro get_by_key(module,key,val) do | |
| quote do |
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 characters
| require Exquisite | |
| defrecord M,[:id,:foo] do | |
| require Unf | |
| require Exquisite | |
| def doit(key,val) do | |
| Unf.get_by_key(__MODULE__,key,val) | |
| end | |
| end | |
| defmodule Unf do | |
| defmacro get_by_key(module,key,val) do |
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 characters
| defmodule NoOrm do | |
| defmacro __using__(_opts) do | |
| quote do | |
| require Amnesia | |
| require Amnesia.Fragment | |
| require Exquisite | |
| require NoOrm | |
| import NoOrm | |
| def gbk(key,val) do | |
| IO.puts "in __using__ #{__MODULE__} key: #{key} val: #{val}" |
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 characters
| defmodule ExquisiteTest do | |
| use ExUnit.Case | |
| require Exquisite | |
| test "tuples work" do | |
| s = Exquisite.match { a, b }, | |
| where: a == { 1, 2 }, | |
| select: b | |
| assert Exquisite.run!(s, { { 1, 2 }, 3 }) == 3 |
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 characters
| ERROR: | |
| Unchecked dependencies for environment dev: | |
| * amnesia [git: "git://github.com/meh/amnesia.git"] | |
| the dependency is overriding another dependency of one of your dependencies, if this is intended set `override: true` in the options | |
| > In /home/vagrant/testing/multi_node/mix.exs: | |
| $ [git: "git://github.com/meh/amnesia.git", dest: "deps/amnesia"] | |
| > In /home/vagrant/testing/multi_node/deps/noorm/mix.exs: | |
| $ [git: "git://github.com/meh/amnesia.git", dest: "/home/vagrant/testing/multi_node/deps/amnesia"] |
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 characters
| rot = fn(lst) -> | |
| [h|t] = lst | |
| t ++ [h] | |
| end | |
| Enum.reduce(1..15,[:worker1,:worker2,:worker3],fn(_,lst) -> | |
| [use_me|t] = lst | |
| IO.puts use_me |
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 characters
| == Compilation error on file lib/noorm.ex == | |
| ** (SyntaxError) lib/noorm.ex:99: unhandled operator -> | |
| src/elixir_translator.erl:614: :elixir_translator.translate_arg/2 | |
| lists.erl:1329: :lists.mapfoldl/3 | |
| lists.erl:1330: :lists.mapfoldl/3 | |
| src/elixir_translator.erl:621: :elixir_translator.translate_args/2 | |
| src/elixir_literal.erl:24: :elixir_literal.translate/2 | |
| src/elixir_translator.erl:614: :elixir_translator.translate_arg/2 | |
| lists.erl:1329: :lists.mapfoldl/3 | |
| lib/noorm.ex:99: THIS_IS_A_Tst.TT.all_by_key/2 |
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 characters
| iex(2)> defmodule MyApp.MigrationExample do | |
| ...(2)> use Ecto.Migration | |
| ...(2)> | |
| ...(2)> def up do | |
| ...(2)> "CREATE TABLE user(id serial PRIMARY_KEY, username text)" | |
| ...(2)> end | |
| ...(2)> | |
| ...(2)> def down do | |
| ...(2)> "DROP TABLE user" | |
| ...(2)> end |