Skip to content

Instantly share code, notes, and snippets.

@jschoch
Created July 11, 2013 11:55
Show Gist options
  • Save jschoch/5974811 to your computer and use it in GitHub Desktop.
Save jschoch/5974811 to your computer and use it in GitHub Desktop.
use Amnesia
defmodule DBA do
def install do
Amnesia.Schema.create
Amnesia.start
use IndexTest
IndexTest.create(disk: [node])
IndexTest.wait
Amnesia.stop
end
def uninstall do
Amnesia.start
IndexTest.destroy
Amnesia.stop
Amnesia.Schema.destroy
end
end
defdatabase IndexTest do
deftable Domains, [:id,:root_id, :name], type: :ordered_set do
end
#deftable Roots, [:id,:name,:domains], type: :ordered_set, index: [:name] do
deftable Roots, [:id,:name,:updated_at,:domains], type: :ordered_set do
def noo(name) do
c = Amnesia.Counter.get(:index_test_roots)
Amnesia.transaction! do
if (c.value! == 0) do
IO.puts "Found zero counter"
count = Roots.last.id
count = (count + 1)
c.increase count
end
end
Amnesia.transaction do
r = Roots[id: c.value,name: name]
c.increase
r.write
r
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment