Skip to content

Sandbox

hobbyquaker edited this page Sep 30, 2017 · 8 revisions

Documentation of the sandbox in which the map and reduce scripts are executed.

Keep in mind that you don't have access to Node.js globals like e.g. require, process or console and that the documents in the sandbox are frozen, so no change on the database contents is possible by the map and reduce scripts.


Classes

api

Functions

emit(item)

push an item to the result array

Typedefs

forEachDocumentCallback : function

api

Kind: global class

api.forEachDocument(callback)

executes a provided function once for each document. Mind that using this function inside a map script can result in O(n²) complexity and could ruin view composition performance. If you need it you should instead use it in the reduce script.

Kind: static method of api

Param Type
callback forEachDocumentCallback

api.getDocument(id) ⇒ object

get a document by id

Kind: static method of api
Returns: object - the document

Param Type Description
id string a document id

api.getProp(document, property) ⇒ *

get a properties value

Kind: static method of api
Returns: * - the properties value or undefined
See: obj-ease documentation

Param Type
document object
property string

api.mqttWildcard(id, pattern) ⇒ array | null

match a string against a MQTT wildcard pattern

Kind: static method of api
See: mqtt-wildcard documentation

Param Type
id string
pattern string

emit(item)

push an item to the result array

Kind: global function

Param Type
item *

forEachDocumentCallback : function

Kind: global typedef

Param Type Description
id string the id of the current document