o-is-contextualize
v0.7.1
Published
Serializable object assertions.
Downloads
8
Maintainers
Readme
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"
}
}