Skip to content

Commit f2bdceb

Browse files
committed
Added support for streaming.
1 parent 7cf1945 commit f2bdceb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

DirtyAdapter.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)