From 76766b3ec725be900222f9ce6105a19f3c0f6153 Mon Sep 17 00:00:00 2001 From: Sheharyar Naseer Date: Thu, 2 Aug 2018 03:02:23 -0400 Subject: [PATCH] Examples for Query.Data --- lib/memento/query/data.ex | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/memento/query/data.ex b/lib/memento/query/data.ex index 2fa0561..9462967 100644 --- a/lib/memento/query/data.ex +++ b/lib/memento/query/data.ex @@ -10,19 +10,24 @@ defmodule Memento.Query.Data do ## Usage + Given a Memento Table: + ``` - # Given a Memento Table defmodule MyApp.User do use Memento.Table, attributes: [:id, :name] end ``` - # You can convert its structs to Mnesia format: + You can convert its structs to Mnesia format: + + ``` Memento.Query.Data.dump(%MyApp.User{id: 1, name: "Sye"}) # => {MyApp.User, 1, "Sye"} + ``` + Or convert it back to a struct: - # Or convert it back to a struct + ``` Memento.Query.Data.load({MyApp.User, 2, "Rick"}) # => %MyApp.User{id: 2, name: "Rick"} ```