{"id":15601204,"url":"https://github.com/hacknlove/monqodb","last_synced_at":"2026-07-10T06:31:37.222Z","repository":{"id":77996085,"uuid":"177959504","full_name":"hacknlove/monqodb","owner":"hacknlove","description":"The mongodb Q promises wrapper that we use at Crowdference","archived":false,"fork":false,"pushed_at":"2015-09-16T07:25:59.000Z","size":240,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T20:51:01.963Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacknlove.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":"2019-03-27T09:19:40.000Z","updated_at":"2019-03-27T09:27:14.000Z","dependencies_parsed_at":"2023-03-03T18:51:42.472Z","dependency_job_id":null,"html_url":"https://github.com/hacknlove/monqodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmonqodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmonqodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmonqodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fmonqodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacknlove","download_url":"https://codeload.github.com/hacknlove/monqodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240810777,"owners_count":19861305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-03T02:19:47.318Z","updated_at":"2025-10-24T02:23:00.093Z","avatar_url":"https://github.com/hacknlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"monqodb\n=======\n\nThe mongodb Q promises wrapper that we use at Crowdference\n   \n## install\n    npm install --save monqodb\n\n\n## use\n    var monqodb = require('monqodb');\n\n\n## Connect to the database\n\n### Zeroconf connection\n\nCurrently when `monqodb` is called without options, it looks process.env for mongodb server's configuration:\n\n    host = MONGO_PORT_27017_TCP_ADDR || MONGO_ADDR || 'localhost'\n    port = MONGO_PORT_27017_TCP_PORT || MONGO_PORT || 27017\n    database = MONGO_PORT_27017_TCP_DATABASE || MONGO_DATABASE || 'test'\n    mongoName = MONGO_PORT_27017_TCP_NAME || MONGO_NAME || 'db'\n\nThat way it needs no configuration to connect to a docker container linked with the name mongo.\n\n### Custom connection.\n\nIf you need to configure the name of the database, (on the server or on the app); to configure other connection parameters like the poolSize or the writeConcern, or if you need to connect to more than one mongodb server or database, you need to pass an object with the configuration parameters.\n\nEach key correspond with the in-application-name of the database, and his value has the options as documented [mongo native docuentation](http://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html#connect)\n\n**IMPORTANT**\nThe `url` must include the database name.\n \n    {\n      db:{\n        url:'mongodb://localhost/mydb',\n        db:{\n          w:1,\n        },\n        server:{\n          poolSize:2,\n          auto_reconnect:true\n        },  \n      },\n      capped:{\n        url:'mongodb://localhost/myCapped',\n        db:{\n          w:0,\n        },\n        server:{\n          poolSize:1,\n          auto_reconnect:true\n        },\n      }\n    }  \n  \n### Connection promise\n\nWhen you call `monqodb` to connect, it returns you a promise that will be fullfilled with `[true, true, ...]` when it has successfully connect to all databases. \n  \n    require `monqodb`;\n    // ...\n    monqodb(options)\n    .then(function(){\n      // YOU know you are connected\n      server.listen(9000) \n    })\n    .catch(function(err){\n      console.log(err.stack);\n      console.log(err)\n    });\n  \n### Default Options\n\nDefault options are\n\n    {\n      db:{\n        w:1,\n      },\n      server:{\n        poolSize:5,\n        auto_reconnect:true\n      },\n    }\n    \nYou can change them before connect, at `monqodb.____defaultOptions`\n  \n## Use\n\nYour databases are members of monqodb and your collections members of those.\n\n    monqodb = require('monqodb');\n    // you have connected previously with foo and bar databases that have some collections\n    // so you can do\n    // monqodb.bar.oneCollectionfromBar.findOne(...).then(...)\n    // monqodb.foo.oneCollectionFromFoo.update(....).then(...)\n    // monqodb.bar.otherCollectionfromBar.insert(...).then(...)\n    // monqodb.foo.otherCollectionFromFoo.remove(...).then(...)\n\n\nWith monqodb you can use   `findOne`, `update`, `insert`, `remove`, `distinct`, `count`, `findAndModify`, `findAndRemove`, `geoNear`, `geoHaystackSearch` in the Q promises way.\n\n`someCollection.someMethod(someOptions..., someCallback)` becomes `someCollection.someMethod(someOptions).then(someCallback)`\n\nOn top of that, monqodb adds the `toArray` with which `someCollection.find(someOptions).toArray(someCallback)` becomes `someCollection.toArray(someOptions).then(someCallback)`\n\n### goodies\n\n* `monqodb.ObjectID` has `ObjectID` \n* `monqodb.close()` closes all monqodb connections.\n\n### using the mongo native api\n\nyou have all connections at the object `monqodb.__connections`, whose keys are the inAppDatabaseNames.\n\nyou have the original collection object at `monqodb.{{inAppDatabaseName}}.{{collectionName}}.collection`\n\n \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fmonqodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacknlove%2Fmonqodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fmonqodb/lists"}