Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1.31 KB

README.md

File metadata and controls

33 lines (25 loc) · 1.31 KB

Examples

Contains a few thoroughly commented examples illustrating how to use the library.

  • simple - Defines a struct type and uses it to record the last time the example was run, along with the number of times the example has run in total.
  • counter - Displays the value of a key in the realm, increments it by one, and quits. Run the example repeatedly to see the number of times it has been run.
  • linked-list - Defines a singly-linked list using a simple struct. Uses the list to record a list of the times the example has been run.
  • users-and-roles - A more complicated example, we define some data structures to represent Users and Roles and the relationships between them.

Running the examples

Checkout the repository and install the dependencies.

git clone https://github.com/codemix/reign.git
cd reign
npm install

Ensure you're using a recent-ish version of node, ideally 5+

node -v

Run each example from the CLI

node examples/simple.js
node examples/counter.js
node examples/linked-list.js
node examples/users-and-roles.js

Run the examples again to ensure that data has been successfully persisted. Files will be created in the data directory (which will be created if it doesn't exist).