0.7.1 • Published 6 years ago

o-is-contextualize v0.7.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

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