Skip to content

arpunk/memento

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memento

Introduction

Memento is an mnesia wrapper for LFE

Installation

Just add it to your rebar.config deps:

{deps, [
 ...
 {memento, {git, "[email protected]:arpunk/memento.git", {branch, "master"}}}
 ...
]}.

And then do the usual:

$ rebar3 compile

Usage

It’s very easy!

(defmodule testing-memento
  (import
    (from memento-table (write 2))
    (from memento-query (select 2))))

(include-lib "memento/include/table.lfe")
(include-lib "memento/include/transaction.lfe")

;; First time?
(memento:stop)
(memento-schema:create)
(memento:start)

;; Let's define some records
(defrecord person
  name
  age)

;; Now let's define our table properties
(set person-opts `[#(type set)
                   #(disc_copies [,(node)])])

;; Once we are ready we can create the table
(create-table person person-opts)

;; And the fun starts
(with-transaction
  (write 'person (make-person name "John Doe" age 31)))

;; Querying
(with-transaction
  (select 'person
          (match-spec
            (((tuple _ name age)) (when (> age 20))
              (tuple 'ok name)))))

About

Mnesia wrapper for LFE

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages