mirror of https://gitee.com/bigwinds/arangodb
Support iterator API in query results
This commit is contained in:
parent
43d1130c24
commit
c253026711
|
|
@ -220,6 +220,12 @@ ArangoQueryCursor.prototype.next = function () {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ArangoQueryCursor.prototype[Symbol.iterator] = function* () {
|
||||||
|
while (this._hasNext) {
|
||||||
|
yield this.next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief explicitly dispose the cursor
|
/// @brief explicitly dispose the cursor
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -729,6 +729,13 @@ AQLGenerator.prototype.next = function() {
|
||||||
return this.cursor.next();
|
return this.cursor.next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AQLGenerator.prototype[Symbol.iterator] = function* () {
|
||||||
|
this._createCursor();
|
||||||
|
for (const item of this.cursor) {
|
||||||
|
yield item;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Deprecated block
|
/// Deprecated block
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,16 @@ GeneralArrayCursor.prototype.next = function() {
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief returns an iterator for the results
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GeneralArrayCursor.prototype[Symbol.iterator] = function* () {
|
||||||
|
while (this._current < this._stop) {
|
||||||
|
yield this._documents[this._current++];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief drops the result
|
/// @brief drops the result
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -393,6 +403,13 @@ SimpleQuery.prototype.next = function () {
|
||||||
return this._execution.next();
|
return this._execution.next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SimpleQuery.prototype[Symbol.iterator] = function* () {
|
||||||
|
this.execute();
|
||||||
|
for (const item of this._execution) {
|
||||||
|
yield item;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief was docuBlock cursorDispose
|
/// @brief was docuBlock cursorDispose
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue