SortProxy

flitter-orm/src/proxy/model/SortProxy~ SortProxy

Proxy that applies a number of sorts to the cursor.


Constructor

new SortProxy(model, sorts, builderopt)

Instantiate the proxy.

Parameters:
Name Type Attributes Description
model module:flitter-orm/src/model/Model~Model | module:flitter-orm/src/proxy/model/ModelProxy~ModelProxy

proxy ref

sorts Array.<string>

array of sorts ('-field', '+field', or 'field')

builder module:flitter-orm/src/model/CursorBuilder~CursorBuilder <optional>

optionally, the cursor builder to use

Extends

Members

builder :module:flitter-orm/src/model/CursorBuilder~CursorBuilder

The cursor builder applied by this proxy.

reference :module:flitter-orm/src/model/Model~Model|module:flitter-orm/src/proxy/model/ModelProxy~ModelProxy

The parent reference of this proxy.

Methods

(async, private) __collection() → {Promise.<mongodb/Collection>}

Get the collection instance for the proxy reference.

Returns:
Type
Promise.<mongodb/Collection>

(async) cursor(filteropt, optsopt) → {Promise.<*>}

Get a cursor for the reference, and apply the proxy's builder.

Parameters:
Name Type Attributes Default Description
filter object <optional>
{}

mongodb filter options

opts object <optional>
{}

optional mongodb params

Returns:
Type
Promise.<*>

(async) deleteMany(filteropt, optsopt) → {Promise.<void>}

Delete the set of records subject to this proxy's restrictions.

Parameters:
Name Type Attributes Default Description
filter object <optional>
{}

mongodb filters to apply

opts object <optional>
{}

optional mongodb params

Returns:
Type
Promise.<void>

(async) deleteOne(filteropt, optsopt) → {Promise.<module:flitter-orm/src/model/Model~Model>}

Delete a single record subject to this proxy's restrictions.

Parameters:
Name Type Attributes Default Description
filter object <optional>
{}

mongodb filters to apply

opts object <optional>
{}

optional mongodb params

Returns:
  • the deleted model
Type
Promise.<module:flitter-orm/src/model/Model~Model>

(async) filter(ref) → {Promise.<module:flitter-orm/src/filter/Filter~Filter>}

Get a filter object whose reference is this proxy.

Parameters:
Name Type Default Description
ref module:flitter-orm/src/model/Model | module:flitter-orm/src/proxy/model/ModelProxy false

(async) find(filteropt, optsopt) → {Promise.<Array.<module:flitter-orm/src/model/Model~Model>>}

Find a set of records subject to this proxy's restrictions.

Parameters:
Name Type Attributes Default Description
filter object <optional>
{}

mongodb filters to apply

opts object <optional>
{}

optional mongodb params

Returns:
Type
Promise.<Array.<module:flitter-orm/src/model/Model~Model>>

(async) findOne(filteropt, optsopt) → {Promise.<module:flitter-orm/src/model/Model~Model>}

Find a single record subject to this proxy's restrictions.

Parameters:
Name Type Attributes Default Description
filter object <optional>
{}

mongodb filters to apply

opts object <optional>
{}

optional mongodb params

(async) from_cursor(cursor) → {Promise.<Array.<module:flitter-orm/src/model/Model~Model>>}

Get an array of model instances from the provided cursor.

Parameters:
Name Type Description
cursor mongodb/cursor
Returns:
Type
Promise.<Array.<module:flitter-orm/src/model/Model~Model>>

limit(to) → {module:flitter-orm/src/proxy/model/LimitProxy~LimitProxy}

Limit the results to a specified number of records.

Parameters:
Name Type Description
to number

sort() → {module:flitter-orm/src/proxy/model/SortProxy~SortProxy}

Sort the result set by the provided field(s).

Parameters:
Name Type Description
sorts... string

variable number of fields to sort

Example
Model.sort('+first_name', '+last_name', '-create_date')