<commit_before>// Returns observable set of objects for given constraints

'use strict';

var memoize             = require('memoizee')
  , resolveFilter       = require('dbjs-persistence/lib/resolve-filter')
  , resolveDirectFilter = require('dbjs-persistence/lib/resolve-direct-filter')
  , ObservableSet       = require('observable-set/primitive')
  , dbDriver            = require('mano').dbDriver;

module.exports = memoize(function (recordType, keyPath, value) {
	var set = new ObservableSet();
	dbDriver.on(recordType + ':' + keyPath, function (event) {
		if (resolveFilter(value, event.data.value)) set.add(event.ownerId);
		else set.delete(event.ownerId);
	});
	if (recordType === 'computed') {
		return dbDriver.searchComputed(keyPath, function (ownerId, data) {
			if (resolveFilter(value, data.value)) set.add(ownerId);
		})(set);
	}
	return dbDriver.searchDirect(keyPath, function (id, data) {<commit_msg>Support no keyPath<commit_after>// Returns observable set of objects for given constraints

'use strict';

var memoize             = require('memoizee')
  , resolveFilter       = require('dbjs-persistence/lib/resolve-filter')
  , resolveDirectFilter = require('dbjs-persistence/lib/resolve-direct-filter')
  , ObservableSet       = require('observable-set/primitive')
  , dbDriver            = require('mano').dbDriver;

module.exports = memoize(function (recordType, keyPath, value) {
	var set = new ObservableSet();
	dbDriver.on(recordType + ':' + keyPath || '&', function (event) {
		if (resolveFilter(value, event.data.value)) set.add(event.ownerId);
		else set.delete(event.ownerId);
	});
	if (recordType === 'computed') {
		return dbDriver.searchComputed(keyPath, function (ownerId, data) {
			if (resolveFilter(value, data.value)) set.add(ownerId);
		})(set);
	}
	return dbDriver.searchDirect(keyPath, function (id, data) {
{'fraction_non_alphanumeric': 0.1444805194805195, 'fraction_numerical': 0.0, 'mean_word_length': 4.39067055393586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5418843', 'n_tokens_mistral': 583, 'n_tokens_neox': 570, 'n_words': 120}