Skip to main content

Add Sample/Initial Data

Now, we need to add in our sample data. For the purposes of this example, we'll be creating five users, five auth records, and one role. At this point, the role won't be connected to any rules, but we will add rules next.

To create 5 _users, we will need to specify 5 username (losDelRio, softCell, dexysMidnightRunners, rightSaidFred, and toniBasil). Each of those users should have a predicate, auth, which references a tempid for an auth record (we use _auth$1, _auth$2, etc. See tempids if you need a review).

Because _user/auth is a multi predicate, the specified object of the predicate needs to be inside of an array. For example is part of the transaction:

[  {    "_id": "_user$1",    "username": "losDelRio",    "auth": ["_auth$1"]  }]

Each auth record should have a

  • _id: _auth$ followed by a tempid (1, 2, 3, 4, 5)
  • id: auth1, auth2, etc.
  • doc: "Basic auth record"
  • roles: a reference to the role (explained below). You'll need to use a tempid, and surround the reference by [ and ], because _auth/roles is a multi predicate.

The role should have a

  • _id: _role$voter, so we can reference it in other parts of the transaction.
  • id: "voter"
  • doc: "A voter can view and edit changes, votes, and users. They cannot edit, auth records."

Add Auth, Users, Role

Use the directions above to add 5 users, 5 auth records, and one role to our ledger.