epha-model

0.2.7 • Public • Published

epha-Model

Build Status Dependency Status devDependency Status

Overview

API

All the following examples assume that you got a client for a specific endpoint:

var model = require("epha-model")("local"); 

Optionally you can overwrite certain functions:

//replace SEPARATOR
model.SEPARATOR = "#"; //defaults to ":"
 
//set your own saltedHash method
model.saltedHash = crypto.saltedHash;
 
//set your own uid generator
model.uid = crypto.uid; 

Unless otherwise stated, all methods return ES6 Promises. See MDN for details.

  1. identity
  1. domain
  1. subject
  1. subjectResource
  1. resource
  1. subResource

client.identity.create(data)

Create a new identity. Adds an id calling client.uid().

model.identity.create({
  birthDate: "1980-01-01",
  gender: "male",
  state: "Zürich",
  email: "marco.egbring@epha.ch",
  password: "pass",
  firstName: "Marco",
  lastName: "Egbring"
});

client.identity.findByEmail(email)

Finds an identity by email.

model.identity.findByEmail("marco.egbring@epah.ch");

Rejects with an error (err.code = not-found) if no identity exists.

client.identity.findById(id)

Finds an identity by id.

model.identity.findById("xyz");

Rejects with an error (err.code = not-found) if no identity exists.

Readme

Keywords

Package Sidebar

Install

npm i epha-model

Weekly Downloads

36

Version

0.2.7

License

none

Last publish

Collaborators

  • epha
  • peerigon