Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
mekanika-adapter
Advanced tools
An abstract adapter class for mekanika adapters.
Alpha release
adapter
is a method for instantiating new Adapter classes, and returning those adapter instances from an internal cache once declared.
Adapters are designed to map Qo - Query objects to a given service (such as a REST API, a database, a filesystem, etc). Typically they will sit on top of a service driver, and do little more than error check the Qo and translate it into a format the driver can process, finally passing (err, res)
back to the callback.
Adapters should by definition be extremely lightweight. Their only 'smart' is their translation layer between Qo and driver APIs. In exceptional circumstances where a driver API is significantly simpler than the default set of Qo actions, an adapter may implement Qo actions via the driver API.
In general an adapter will map as much of the Qo specification that is natively supported by the underlying driver.
New Adapters are instantiated as follows:
var myadapter = adapter.new( 'myadapter', defaultConfig );
// adapter('myadapter') instanceof adapter.Adapter
// -> true
All adapters can be retrieved using the adapter( name )
format, and are stored in the adapter
cache.
adapter
has the following static methods:
Adapters map a query request object to corresponding actions of a particular service. To do this, adapters must implement an .exec( query, cb )
method that:
cb
callback passing cb( err, res )
err
: Error object or null
res
: Results of successful execution (or undefined
)All Adapters are EventEmitters (based on EventEmitter2)
The initial Adapter
class is very simple:
var moo = adapter.new( 'moo', {prop: true} );
// -> { identity: 'moo', config: {prop: true} }
On the Prototype
{}
object (used to store config)Error('Not implemented')
.exec( query, cb )
Two paths for finding records, either via:
Identifiers
{identifiers: ['xyz']}
Constraints
[{field:'name', operator:'eq', condition:'joe'}]
There are two (independent) update paths, updating via either/or:
Modifiers
{set: $field, value: $value}
{inc: $field, value: $value}
(can be negative)Content
content: [ {vip: true} ]
Where multiple identifiers
are set, the content or modifiers should be applied to all ids. If no identifiers are set, the update will be applied to where
conditions, eg:
{
action: 'update',
resource: 'users',
modifiers: [{set:'vip', value: true}],
where: [{field:'points', operator:'gte', constraint:500}]
}
// Sets 'vip' to true on users who have points >= 500
npm install --production
For development, requires globally installed:
MIT
FAQs
Abstract mekanika adapter class
We found that mekanika-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.