OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

ResourceFilter

Summary

Defines a storage filter.

A filter is a uniform way of filtering results common to all storages. A filter can contain only one "or" operation, one "nor" operation and one "and" operation.

var filter = new ResourceFilter()
.equal('field1', 42)
.notEqual('field2', 42)
.greaterThan('field3', 42)
.greaterThanEqual('field4', 42)
.in('field5', [42])
.lesserThan('field6', 42)
.lesserThanEqual('field7', 42)
.regex('field8', /^Something/i)
.search('query')
.or([
  new ResourceFilter().equal('field8', 42),
  new ResourceFilter().notIn('field9', [42])
])
.nor([
  new ResourceFilter().equal('field10', 42),
  new ResourceFilter().notIn('field11', [42])
)],
.and([
  new ResourceFilter().equal('field12', 42),
  new ResourceFilter().notIn('field13', [42])
)];

Constructor

ResourceFilter

Syntax

ResourceFilter

()

Summary

Methods

addComparisonOperation

Syntax

addComparisonOperation

(
  • field
  • value
  • Resource
  • The
)
ResourceFilter private

Summary

Adds a comparison operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

addLogicalOperation

Syntax

addLogicalOperation

(
  • filters
)
ResourceFilter private

Summary

Adds a logical operation to the filter.

Only one logical operation can be added in a filter.

Parameters:

  • filters Array

    The list of filters

Returns:

ResourceFilter:

The actual filter

and

Syntax

and

(
  • filters
)
ResourceFilter

Summary

Adds an "and" operation to the filter.

Parameters:

  • filters Array

    The list of filters

Returns:

ResourceFilter:

The actual filter

equal

Syntax

equal

(
  • field
  • value
)
ResourceFilter

Summary

Adds an equal operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

equal

Syntax

equal

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "not equal" operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

getComparisonOperation

Syntax

getComparisonOperation

(
  • operator
  • field
)
Object | Null

Summary

Gets an operation from filter or sub filters.

Parameters:

  • operator String

    Operation operator

  • field String

    Operation field

Returns:

Object | Null:

The operation with: -String type The operation type -String field The operation field -String|Number|Boolean|Date|Array value The operation value

getLogicalOperation

Syntax

getLogicalOperation

(
  • operator
)
Object | Null

Summary

Gets a logical operation from filter.

Parameters:

  • operator String

    Logical operator to look for

Returns:

Object | Null:

The operation with: -String type The operation type -Array filters The list of filters inside the logical operation

greaterThan

Syntax

greaterThan

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "greater than" operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

greaterThanEqual

Syntax

greaterThanEqual

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "greater than or equal" operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

hasOperation

Syntax

hasOperation

(
  • operator
)
Boolean

Summary

Tests if an operation has already been specified.

Parameters:

  • operator String

    Operation operator

Returns:

Boolean:

true if the operation has already been added to this filter, false otherwise

in

Syntax

in

(
  • field
  • value
)
ResourceFilter

Summary

Adds an "in" operation to the filter.

Parameters:

  • field String

    The name of the field

  • value Array

    The value to compare the field to

Returns:

ResourceFilter:

The actual filter

in

Syntax

in

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "not in" operation to the filter.

Parameters:

  • field String

    The name of the field

  • value Array

    The value to compare the field to

Returns:

ResourceFilter:

The actual filter

isValidType

Syntax

isValidType

(
  • value
  • The
)
Boolean private

Summary

Validates the type of a value.

Parameters:

  • value String

    The value to test

  • The Array

    list of authorized types as strings

Returns:

Boolean:

true if valid, false otherwise

lesserThan

Syntax

lesserThan

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "lesser than" operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

lesserThanEqual

Syntax

lesserThanEqual

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "lesser than equal" operation to the filter.

Parameters:

Returns:

ResourceFilter:

The actual filter

nor

Syntax

nor

(
  • filters
)
ResourceFilter

Summary

Adds a "nor" operation to the filter.

Parameters:

  • filters Array

    The list of filters

Returns:

ResourceFilter:

The actual filter

or

Syntax

or

(
  • filters
)
ResourceFilter

Summary

Adds a "or" operation to the filter.

Parameters:

  • filters Array

    The list of filters

Returns:

ResourceFilter:

The actual filter

regex

Syntax

regex

(
  • field
  • value
)
ResourceFilter

Summary

Adds a "regular expression" operation to the filter.

Parameters:

  • field String

    The name of the field

  • value RegExp

    The regular expression to compare the field to

Returns:

ResourceFilter:

The actual filter

Properties

operations

Syntax

operations

Array final

Summary

The list of operations.

OPERATORS

Syntax

OPERATORS

Object final static

Summary

The available operators.