o-is-contextualize

0.7.1 • Public • Published

Object Is: Contextualize

The idea behind this module is to allow to bind properties on every call done to an oIs 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 oIs = require('o-is').extend({
	contextualize: require('o-is-contextualize'),
	elasticsearch: require('o-is-elasticsearch')
})

const condition = oIs()
	.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 o-is-contextualize

Weekly Downloads

2

Version

0.7.1

License

MIT

Last publish

Collaborators

  • aghost7