From b6a515f8703b3fc863500333d918262a432e1e05 Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Tue, 6 Jan 2009 16:52:29 -0500 Subject: [PATCH] Add docs about order_by Hash/OrderedHash --- lib/mongo/query.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/mongo/query.rb b/lib/mongo/query.rb index c43ca4f..1357c1a 100644 --- a/lib/mongo/query.rb +++ b/lib/mongo/query.rb @@ -42,11 +42,16 @@ module XGen # number_to_return :: Max number of records to return. (Called :limit # in calls to Collection#find.) # - # order_by :: If not +nil+, specifies record return order. Either hash - # of field names as keys and 1/-1 as values; 1 == - # ascending, -1 == descending, or array of field names - # (all assumed to be sorted in ascending order). (Called - # :sort in calls to Collection#find.) + # order_by :: If not +nil+, specifies record sort order. May be either + # a hash or an array. If an array, it should be an array + # of field names which will all be sorted in ascending + # order. If a hash, it may be either a regular Hash or an + # OrderedHash. The keys should be field names, and the + # values should be 1 (ascending) or -1 (descending). Note + # that if it is a regular Hash then sorting by more than + # one field probably will not be what you intend because + # key order is not preserved. (order_by is called :sort in + # calls to Collection#find.) def initialize(sel={}, return_fields=nil, number_to_skip=0, number_to_return=0, order_by=nil) @number_to_skip, @number_to_return, @order_by = number_to_skip, number_to_return, order_by self.selector = sel