Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: coresmart/persistencejs
base: master
...
head fork: calendar42/persistencejs
compare: master
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 67 additions and 0 deletions.
  1. +55 −0 lib/persistence.js
  2. +12 −0 lib/persistence.store.sql.js
55 lib/persistence.js
View
@@ -1457,6 +1457,60 @@ persistence.get = function(arg1, arg2) {
};
/**
+ * Filter that makes sure that either its left and right filter match
+ * @param left left-hand filter object
+ * @param right right-hand filter object
+ */
+ function MultipleOrFilter (arr) {
+ this.filters = null;
+ this.filters = arr;
+ }
+
+ MultipleOrFilter.prototype.match = function (o) {
+ for (var i = 0; i < this.filters.length; i++) {
+ if (this.filters[i].match(o)) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ MultipleOrFilter.prototype.makeFit = function(o) {
+ for (var i = 0; i < this.filters.length; i++) {
+ this.filters[i].makeFit(o);
+ }
+ };
+
+ MultipleOrFilter.prototype.makeNotFit = function(o) {
+ for (var i = 0; i < this.filters.length; i++) {
+ this.filters[i].makeNotFit(o);
+ }
+ };
+
+ MultipleOrFilter.prototype.toUniqueString = function() {
+ var str = "";
+ for (var i = 0; i < this.filters.length; i++) {
+ str += this.filters[i].toUniqueString();
+ if (i < this.filters.length -1) {
+ str += " OR "
+ }
+ }
+ return str;
+ };
+
+ MultipleOrFilter.prototype.subscribeGlobally = function(coll, entityName) {
+ for (var i = 0; i < this.filters.length; i++) {
+ this.filters[i].subscribeGlobally(coll, entityName);
+ }
+ };
+
+ MultipleOrFilter.prototype.unsubscribeGlobally = function(coll, entityName) {
+ for (var i = 0; i < this.filters.length; i++) {
+ this.filters[i].unsubscribeGlobally(coll, entityName);
+ }
+ };
+
+ /**
* Filter that checks whether a certain property matches some value, based on an
* operator. Supported operators are '=', '!=', '<', '<=', '>' and '>='.
* @param property the property name
@@ -1542,6 +1596,7 @@ persistence.get = function(arg1, arg2) {
persistence.NullFilter = NullFilter;
persistence.AndFilter = AndFilter;
persistence.OrFilter = OrFilter;
+ persistence.MultipleOrFilter = MultipleOrFilter;
persistence.PropertyFilter = PropertyFilter;
/**
12 lib/persistence.store.sql.js
View
@@ -523,6 +523,18 @@ function config(persistence, dialect) {
+ this.right.sql(meta, alias, values) + ")";
};
+ persistence.MultipleOrFilter.prototype.sql = function (meta, alias, values) {
+ var str = "(";
+ for (var i = 0; i < this.filters.length; i++) {
+ str += this.filters[i].sql(meta, alias, values);
+ if (i < this.filters.length -1) {
+ str += " OR "
+ }
+ }
+ str += ")";
+ return str;
+ };
+
persistence.PropertyFilter.prototype.sql = function (meta, alias, values) {
var tm = persistence.typeMapper;
var aliasPrefix = alias ? "`" + alias + "`." : "";

No commit comments for this range

Something went wrong with that request. Please try again.