Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

@rule.js/contextualize

0.17.1 • Public • Published

Rule.js: Contextualize

The idea behind this module is to allow to bind properties on every call done to a Rule object as though the property was present on every object you're testing against. This allows, for example, one to use the elasticsearch generator with user login data. For example:

const Rule = require('@rule.js/core').extend({
    contextualize: require('@rule.js/contextualize'),
    elasticsearch: require('@rule.js/elasticsearch')
})
 
const condition = Rule()
    .propEqual('user.name', 'creator')
 
const query = condition
    .contextualize({
        user: {
            name: 'foobar'
        }
    })
    .elasticsearch()
 

The query variable would then contain an elasticsearch query which looks like the following:

{
    "term": {
        "creator": "foobar"
    }
}

Install

npm i @rule.js/contextualize

DownloadsWeekly Downloads

0

Version

0.17.1

License

MIT

Unpacked Size

18.4 kB

Total Files

6

Last publish

Collaborators

  • avatar