Object that specifies method mappings for methods from the number library that are required by the driver. Set this as static property for mappings to static methods (properties of the constructor) and to instance property for mappings to instance methods (properties of the constructor's prototype). You may also set both of the above to provide static mappings for some methods and instance mappings for others. For any required method, one mapping is sufficient (otherwise the driver will prefer instance over static).

Unless otherwise specified, the required operations are binary (i.e. they operate on two number objects). This means that static methods take 2 parameters and instance methods have this context as the 1st number object and pass 2nd number as one parameter.

You can specify each method mapping as either string or a function. If string, the driver will use constructor's or prototype's property by that name for static or instance method respectively. You may also provide a function for either static or instance method (as long as it follows the rules for arguments and this context described in previous paragraph). This allows you to customize implementation if needed.

The following assumptions can be made about the argument types:

  • For static methods, you may assume that the first argument is the number object but second argument may be either number object, string or Javascript number. This should fit the signatures of static methods from number libraries, which typically assume that both arguments may be either number object, string or Javascript number.
  • For instance methods, this context is the number object but the argument may be number object, string or Javascript number. Typically number libraries make the same assumption.
All properties are optional. For any method mapping property, if not set, the driver will look for methods with list of names as specified. Unless otherwise specified, the driver will look first for each instance method on that list and then for each static. If the mapping is not specified and none of the methods on the list could be found, NoSQLArgumentError will result.

The above means that you only need to set mappings for methods with non-typical names that would not be found on corresponding name list or if you with to customize thier implementation. In particular, for 4 tested number libraries mentioned in DBNumberConfig, no mappings are required.

Hierarchy

  • NumberLibMethods

Properties

add?: string | ((n1: any, n2: any) => any)

Add two numbers n1 and n2, return number object with value of n1 + n2. If not set, the driver will look for methods named plus and add in that order.

compare?: string | ((n1: any, n2: any) => number)

Compare two numbers n1 and n2. Return value of this function should be > 0 if n1 > n2, = 0 if n1 = n2 and < 0 if n1 < n2. If not set, the driver will look for methods named comparedTo, compareTo, cmp and compare in that order

divide?: string | ((n1: any, n2: any) => any)

Divide number n1 by n2, return number object with value of n1 / n2. If not set, the driver will look for methods named dividedBy, divide and div in that order.

multiply?: string | ((n1: any, n2: any) => any)

Multiply numbers n1 and n2, return number object with value n1 * n2. If not set, the driver will look for methods named times, multipliedBy, multiply and mul in that order.

subtract?: string | ((n1: any, n2: any) => any)

Subtract number n2 from n1, return number object with value of n1 - n2. If not set, the driver will look for methods named minus, sub and subtract in that order.

valuesEqual?: string | ((n1: any, n2: any) => boolean)

Determine if two numbers are equal. Should return true/false. This property may be useful for equality checks during query processing which is usually faster than numeric comparison via compare. If not set, the driver will look for instance methods equals, isEqualTo and eq in that order. If not found, the driver will use compare for equality checks.

Generated using TypeDoc