Skip to content

Commit

Permalink
feat: Added readFrom method to cursor
Browse files Browse the repository at this point in the history
Allows you to specify the read preference for a cursor.
  • Loading branch information
notheotherben committed Oct 30, 2015
1 parent a914a64 commit fe1ab5f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,13 @@ export class Cursor<TDocument extends { _id?: any }, TInstance> {
skip(skip: number): Cursor<TDocument, TInstance> {
return new Cursor(this.model, this.conditions, this.cursor.skip(skip));
}

/**
* Returns a new cursor which will read from the specified node type.
* @param {String} type The type of node to read from - see https://docs.mongodb.org/manual/core/read-preference/
* @return {Cursor} The new cursor which reads from the specified node type
*/
readFrom(type: string): Cursor<TDocument, TInstance> {
return new Cursor(this.model, this.conditions, this.cursor.setReadPreference(type));
}
}

0 comments on commit fe1ab5f

Please sign in to comment.