epha-model
v0.2.7
Published
Preconfigured dynamise client and table definitions
Downloads
2
Readme
epha-Model
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.
- identity
- domain
- subject
- model.subject.create()
- model.subject.findById()
- model.subject.findByIdentity()
- model.subject.findByDomain()
- subjectResource
- model.subjectResource.findByType()
- model.subjectResource.findByTypeAndDateRange()
- model.subjectResource.findAll()
- resource
- subResource
- model.subResource.create()
- model.subResource.findByParentResource()
- model.subResource.fetchByParentResource()
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: "[email protected]",
password: "pass",
firstName: "Marco",
lastName: "Egbring"
});
client.identity.findByEmail(email)
Finds an identity by email.
model.identity.findByEmail("[email protected]");
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.