{"id":19142371,"url":"https://github.com/eldoy/mngo","last_synced_at":"2026-05-16T09:33:05.671Z","repository":{"id":57299363,"uuid":"145503864","full_name":"eldoy/mngo","owner":"eldoy","description":"MongoDB client with support for events","archived":false,"fork":false,"pushed_at":"2018-12-30T16:48:36.000Z","size":162,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-03T21:53:57.535Z","etag":null,"topics":["client","events","mongodb","proxy"],"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/eldoy.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":"2018-08-21T03:54:48.000Z","updated_at":"2022-06-04T21:55:04.000Z","dependencies_parsed_at":"2022-08-26T18:02:51.378Z","dependency_job_id":null,"html_url":"https://github.com/eldoy/mngo","commit_stats":null,"previous_names":["fugroup/mngo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eldoy/mngo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldoy%2Fmngo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldoy%2Fmngo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldoy%2Fmngo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldoy%2Fmngo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eldoy","download_url":"https://codeload.github.com/eldoy/mngo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldoy%2Fmngo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33096887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["client","events","mongodb","proxy"],"created_at":"2024-11-09T07:27:00.621Z","updated_at":"2026-05-16T09:33:05.655Z","avatar_url":"https://github.com/eldoy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MNGO Evented MongoDB Database Client\nA thin layer on top of the native mongodb driver with support for events. Updates, inserts and deletes can be subscribed to for use with web sockets.\n\nThe client retries connection if the database server is not ready, which is perfect for container environments. You'll love Mngo if you're using docker or rkt.\n\nAny changes returns the full document. You can change the database name for a connection or a single collection transaction on the fly which is great for multi-database environments. MIT licensed.\n\n### INSTALL\n```npm i mngo``` or ```yarn add mngo```\n\n### USAGE\n```javascript\n\nconst mongo = require('mngo')\n\n// Returns a Connection object\nconst db = await mongo.connect(\n  {\n    url: 'mongodb://localhost:27017',\n    name: 'mngo'\n  },\n  {\n    poolSize: 100\n  }\n)\n\n// Get collection\nconst projectCollection = db('project')\n\n// Collection with options\nconst projectCollection = db('project', {\n  db: 'name' // Db name only for this collection\n})\n\n// Insert\nawait db('project').insert({ name: 'hello' })\nawait db('project').insert({ name: 'hello' }, {}) // Last parameter are native mongodb options\n\n// Update\nawait db('project').update({ name: 'hello' }, { name: 'newname' })\n\n// Find first match, returns an single object or null\nawait db('project').first({ name: 'hello' })\n\n// Find many returns an array\nawait db('project').find({ name: 'hello' })\n\n// Delete\nawait db('project').delete({ name: 'hello' })\n\n// Object ID\ndb.id()          // Returns new object id\ndb.id(string_id) // Returns mongodb id string as object\n\n// Change database on the same connection\ndb.database('name')\n\n// Check connection status\ndb.connected()\n\n// Native mongodb client\ndb.client\n\n// Register events\nmongo.on('change', (db, type, name, data) =\u003e {\n  console.log('Database changed!')\n  console.log(db)   // Name of database\n  console.log(type) // Type is first, find, insert, update or delete\n  console.log(name) // Name of collection\n  console.log(data  // The data\n})\n\n// Add '$' in front to also emit change events\nawait db('project').$find()\nawait db('project').$first()\nawait db('project').$insert()\nawait db('project').$update()\nawait db('project').$delete()\n```\nThe connections are automatically pooled and re-used if possible. Enjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldoy%2Fmngo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feldoy%2Fmngo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldoy%2Fmngo/lists"}