@@ -81,63 +81,6 @@ def multiple_from_db(ids)
8181 ids . empty? ? [ ] : from_database ( ids )
8282 end
8383
84- # Return true if any documents exist in the criteria.
85- #
86- # @example Determine if any documents exist
87- # criteria.any?
88- #
89- # @example Determine if any documents match a block
90- # criteria.any? { |doc| doc.name == "John" }
91- #
92- # @param [ Object... ] *args Args to delegate to the target.
93- #
94- # @param [ Proc ] &block Block to delegate to the target.
95- #
96- # @return [ true | false ] If any documents exist.
97- def any? ( *args , &block )
98- return entries . any? ( *args , &block ) if args . any? || block_given?
99-
100- limit ( 1 ) . count > 0
101- end
102-
103- # Return true if only one document exists in the criteria.
104- #
105- # @example Determine if only one document exists
106- # criteria.one?
107- #
108- # @example Determine if only one document matches a block
109- # criteria.one? { |doc| doc.name == "John" }
110- #
111- # @param [ Object... ] *args Args to delegate to the target.
112- #
113- # @param [ Proc ] &block Block to delegate to the target.
114- #
115- # @return [ true | false ] If only one document exists.
116- def one? ( *args , &block )
117- return entries . one? ( *args , &block ) if args . any? || block_given?
118-
119- limit ( 2 ) . count == 1
120- end
121-
122- # Return true if more than one document exists in the criteria.
123- #
124- # @example Determine if many documents exist
125- # criteria.many?
126- #
127- # @example Determine if many documents match a block
128- # criteria.many? { |doc| doc.name.start_with?("J") }
129- #
130- # @param [ Object... ] *args Args to delegate to the target.
131- #
132- # @param [ Proc ] &block Block to delegate to the target.
133- #
134- # @return [ true | false ] If many documents exist.
135- def many? ( *args , &block )
136- return entries . many? ( *args , &block ) if args . any? || block_given?
137-
138- limit ( 2 ) . count > 1
139- end
140-
14184 private
14285
14386 # Get the finder used to generate the id query.
0 commit comments