findOne()

Finds a single events on the specified Stream that matches the specified options.

Octave.Event.findOne(streamId, options)

Parameters

ParameterTypeRequiredDescription
streamIdStringYesThe unique ID of the Stream.
optionsObjectYesAn optional object literal of query options:
options.filterStringNoA filter string.
options.startIntegerNoThe start index of the search (default value is 0).
options.limitIntegerNoThe maximum response size (default value is 20).
options.sortStringNoThe string representation of the member key to sort the results over (default value is the creation date).
options.orderStringNoSpecifies the sort order. Can be set to asc and desc (default value is desc).

Returns

A JSON representation of a single matching Event.

Example

Request

//find the most recent events where x > 1:
var event = Octave.Event.findOne("s5b7c2258c4eaa25486be2ed1", {"filter": "x > 1", "sort":"creationDate"});
// event  now contains the matching event
// event == {elems: { x:1 },creationDate: 1534865286261,...}

Response

// event  now contains the matching event
{
  elems:
  {
    x:1
  },
  creationDate: 1534865286261,
  ...
}