@janiscommerce/active-client

A simple module for getting an Active Client from a field and a value


License
ISC
Install
npm install @janiscommerce/active-client@1.2.2

Documentation

active-client

Build Status Coverage Status

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: type String, the field name. eg. 'name'.
  • value: type String|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
	}
 */