active-client
ActiveClient is a simple module for getting an Active Client from a field and a value. The module only has one method and a Model for the get.
Installation
npm install @janiscommerce/active-client
Settings
This package uses the Settings package for handle settings.
The setting key is clients
and the available settings are the following
Setting | Default Value | Description |
---|---|---|
databaseKey | _default | The database key from DB configuration |
table | clients | The clients table name |
API
-
getByField(field, value)
ASYNCHRONOUS, Search the client by a field and value given.
-
field
: typeString
, the field name. eg. 'name'. -
value
: typeString|Integer
, the field value. eg. 'foo'.
Returns a Object
with the client found or false
if client not found for field
with that value
.
Usage
const ActiveClient = require('@janiscommerce/active-client');
const client = await ActiveClient.getByField('name', 'client-name');
/**
Expected output:
{
id: 1,
name: 'client-name',
status: 5
}
*/