aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Doc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r--src/fields/Doc.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index f6b7708b3..0dd9a9fc8 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -24,6 +24,7 @@ import { listSpec } from './Schema';
import { ComputedField, ScriptField } from './ScriptField';
import { BoolCast, Cast, DocCast, FieldValue, NumCast, StrCast, ToConstructor, toList } from './Types';
import { containedFieldChangedHandler, deleteProperty, GetEffectiveAcl, getField, getter, makeEditable, makeReadOnly, setter, SharingPermissions } from './util';
+import { KEY } from 'google-maps';
export let ObjGetRefField: (id: string, force?: boolean) => Promise<Doc | undefined>;
export let ObjGetRefFields: (ids: string[]) => Promise<Map<string, Doc | undefined>>;
@@ -1366,6 +1367,13 @@ export namespace Doc {
export const FilterAny = '--any--';
export const FilterNone = '--undefined--';
+ export function hasDocFilter(container: Opt<Doc>, key: string, value: string | undefined, fieldPrefix?: string) {
+ if (!container) return;
+ const filterField = '_' + (fieldPrefix ? fieldPrefix + '_' : '') + 'childFilters';
+ const childFilters = StrListCast(container[filterField]);
+ return childFilters.some(filter => filter.split(FilterSep)[0] === key && (value === undefined || filter.split(FilterSep)[1] === value));
+ }
+
// filters document in a container collection:
// all documents with the specified value for the specified key are included/excluded
// based on the modifiers :"check", "x", undefined