Skip to content

SQL where-like filter function builder (@sixriver/where-filter)

License

Notifications You must be signed in to change notification settings

6RiverSystems/where-filter

Repository files navigation

where-filter

Effectively a fork of loopback-filters

Works according to Loopback Where Criteria spec. With the additional support for array predicates some and all.

some

const condition = {
	lines: {
		some: {
			status: 'good',
		},
	},
};

const data = {
	lines: [
		{
			status: 'good',
		},
		{
			status: 'bad',
		},
	],
};

const result = whereFilter(condition)(data);

console.log(result);
// true

all

const condition = {
	lines: {
		all: {
			status: 'good',
		},
	},
};

const data = {
	lines: [
		{
			status: 'good',
		},
		{
			status: 'good',
		},
	],
};

const result = whereFilter(condition)(data);

console.log(result);
// true