@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"
	}
}

Package Sidebar

Install

npm i @rule.js/contextualize

Weekly Downloads

2

Version

0.17.1

License

MIT

Unpacked Size

18.4 kB

Total Files

6

Last publish

Collaborators

  • aghost7