{"id":23826251,"url":"https://github.com/moeriki/mongo-iterable-cursor","last_synced_at":"2026-04-18T19:33:30.050Z","repository":{"id":57314470,"uuid":"83219630","full_name":"moeriki/mongo-iterable-cursor","owner":"moeriki","description":"Turn your mongodb cursor into an async iterable.","archived":false,"fork":false,"pushed_at":"2019-07-17T07:11:06.000Z","size":202,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T04:35:49.010Z","etag":null,"topics":["async","es2017","iterable","mongodb"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moeriki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-26T15:36:09.000Z","updated_at":"2019-07-17T07:11:08.000Z","dependencies_parsed_at":"2022-09-20T23:20:42.958Z","dependency_job_id":null,"html_url":"https://github.com/moeriki/mongo-iterable-cursor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/moeriki/mongo-iterable-cursor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeriki%2Fmongo-iterable-cursor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeriki%2Fmongo-iterable-cursor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeriki%2Fmongo-iterable-cursor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeriki%2Fmongo-iterable-cursor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moeriki","download_url":"https://codeload.github.com/moeriki/mongo-iterable-cursor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeriki%2Fmongo-iterable-cursor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","es2017","iterable","mongodb"],"created_at":"2025-01-02T12:16:52.259Z","updated_at":"2026-04-18T19:33:30.026Z","avatar_url":"https://github.com/moeriki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch3 align=\"center\"\u003emongo-iterable-cursor\u003c/h3\u003e\n  \u003cp align=\"center\"\u003eTurn your \u003ca href=\"https://github.com/mongodb/node-mongodb-native\"\u003emongodb\u003c/a\u003e cursor into an \u003ca href=\"https://github.com/tc39/proposal-async-iteration\"\u003easync iterable\u003c/a\u003e.\u003cp\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/mongo-iterable-cursor\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/v/mongo-iterable-cursor.svg\" alt=\"npm version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://travis-ci.org/Moeriki/mongo-iterable-cursor\"\u003e\n      \u003cimg src=\"https://travis-ci.org/Moeriki/mongo-iterable-cursor.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/github/Moeriki/mongo-iterable-cursor?branch=master\"\u003e\n      \u003cimg src=\"https://coveralls.io/repos/github/Moeriki/mongo-iterable-cursor/badge.svg?branch=master\" alt=\"Coverage Status\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://david-dm.org/moeriki/mongo-iterable-cursor\"\u003e\n      \u003cimg src=\"https://david-dm.org/moeriki/mongo-iterable-cursor/status.svg\" alt=\"dependencies Status\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\nAsync iteration is a stage-3 proposal. Use with caution!\n\n## Without babel\n\nYou'll need Node.js 4 or above.\n\n```js\nconst { MongoClient } = require('mongodb');\nconst iterable = require('mongo-iterable-cursor');\n\nMongoClient.connect('mongodb://localhost:27017/test')\n    .then((db) =\u003e {\n        const users = db.collection('users');\n\n        for (const pendingUser of iterable(users.find())) {\n            pendingUser.then((user) =\u003e {\n                // handle user\n            });\n        }\n    })\n;\n```\n\nYou can use [for-await](https://www.npmjs.com/package/for-await) to handle your items serially.\n\n```js\nconst forAwait = require('for-await');\nconst { MongoClient } = require('mongodb');\nconst iterable = require('mongo-iterable-cursor');\n\nMongoClient.connect('mongodb://localhost:27017/test')\n    .then((db) =\u003e {\n        const users = db.collection('users');\n        return forAwait((user) =\u003e {\n          // handle user\n        }).of(iterable(users.find()));\n    })\n;\n```\n\n## With babel\n\nYour setup needs to support async generator functions. If you are using Babel you'll need at least the following config.\n\n```js\n{\n  \"presets\": [\"es2017\"], // or use Node.js v8 which includes async/await\n  \"plugins\": [\n    \"transform-async-generator-functions\"\n  ]\n}\n```\n\n```js\nconst iterable = require('mongo-iterable-cursor');\nconst { MongoClient } = require('mongodb');\n\n(async () =\u003e {\n  const db = await MongoClient.connect('mongodb://localhost:27017/test');\n  const users = db.collection('users');\n\n  for await (const user of iterable(users.find())) {\n    //\n  }\n})();\n```\n\n## Register\n\nRequiring `mongo-iterable-cursor/register` adds `[Symbol.asyncIterator]` to the [mongodb cursor](http://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html) `Cursor.prototype`.\n\n```js\nrequire('mongo-iterable-cursor/register');\n\nconst { MongoClient } = require('mongodb');\n\n(async () =\u003e {\n  const db = await MongoClient.connect('mongodb://localhost:27017/test');\n  const users = db.collection('users');\n\n  for await (const user of users.find()) {\n    //\n  }\n})();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoeriki%2Fmongo-iterable-cursor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoeriki%2Fmongo-iterable-cursor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoeriki%2Fmongo-iterable-cursor/lists"}