File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,25 @@ module.exports = (function () {
241241 cb ( null , resultSet ) ;
242242 } ,
243243
244+ // Stream models from the collection
245+ // using where, limit, skip, and order
246+ // In where: handle `or`, `and`, and `like` queries
247+ stream : function ( collectionName , options , stream ) {
248+ var dataKey = dataPrefix + collectionName ;
249+ var data = connections [ collectionName ] . db . get ( dataKey ) || [ ] ;
250+
251+ // Get indices from original data which match, in order
252+ var matchIndices = getMatchIndices ( data , options ) ;
253+
254+ // Write out the stream
255+ _ . each ( matchIndices , function ( matchIndex , cb ) {
256+ stream . write ( _ . clone ( data [ matchIndex ] ) ) ;
257+ } ) ;
258+
259+ // Finish stream
260+ stream . end ( ) ;
261+ } ,
262+
244263 // Update one or more models in the collection
245264 update : function ( collectionName , options , values , cb ) {
246265 var my = this ;
You can’t perform that action at this time.
0 commit comments