{"id":17377381,"url":"https://github.com/pradel/mongodb-bluebird","last_synced_at":"2025-04-15T07:31:15.222Z","repository":{"id":22584134,"uuid":"25925760","full_name":"pradel/mongodb-bluebird","owner":"pradel","description":"A simple package mongodb promise","archived":false,"fork":false,"pushed_at":"2018-03-16T09:04:15.000Z","size":22,"stargazers_count":16,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T18:21:24.958Z","etag":null,"topics":["bluebird","mongodb","nodejs"],"latest_commit_sha":null,"homepage":null,"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/pradel.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":"2014-10-29T14:52:06.000Z","updated_at":"2019-02-09T15:48:37.000Z","dependencies_parsed_at":"2022-08-20T20:20:56.172Z","dependency_job_id":null,"html_url":"https://github.com/pradel/mongodb-bluebird","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fmongodb-bluebird","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fmongodb-bluebird/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fmongodb-bluebird/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fmongodb-bluebird/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pradel","download_url":"https://codeload.github.com/pradel/mongodb-bluebird/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248744077,"owners_count":21154803,"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":["bluebird","mongodb","nodejs"],"created_at":"2024-10-16T05:05:50.092Z","updated_at":"2025-04-15T07:31:14.941Z","avatar_url":"https://github.com/pradel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongodb-bluebird\n\n[![Build Status](https://travis-ci.org/pradel/mongodb-bluebird.svg?branch=master)](https://travis-ci.org/pradel/mongodb-bluebird)\n\nAdd promise to the [node-mongodb-native](https://github.com/mongodb/node-mongodb-native).\n\n## Installation\n\n```\nnpm install mongodb-bluebird\n```\n\n## Quick examples\n\n```\nvar mongo = require('mongodb-bluebird');\n//open connection to the database\nmongo.connect(\"mongodb://localhost:27017/mongodb-bluebird\").then(function(db) {\n    //close connection to the database\n    return db.close().then(function() {\n        console.log('success');\n    });\n}).catch(function(err) {\n  console.error(\"something went wrong\");\n});\n\n//find users\nmongo.connect(\"mongodb://localhost:27017/mongodb-bluebird\").then(function(db) {\n    //get the user collection\n    var users = db.collection('users');\n    return users.find().then(function(users) {\n        console.log(users);\n    }).catch(function(err) {\n        console.error(\"something went wrong\");\n    });\n});\n\n//find one user\nusers.findOne().then(function(user) {\n    console.log(user);\n});\n\n//find by id\nusers.findById('507f191e810c19729de860ea').then(function(user) {\n    console.log(user);\n});\n```\n\n### Get a collection\n\n```\nvar users = db.collection('users');\n```\n\nThe `_id` field will be automatically converted into ObjectId.\nIf you want to convert automatically some other fields into ObjectId just pass an array as second parameter :\n\n```\nvar users = db.collection('users', {\n\tObjectIds: [`your', 'fields']\n});\n```\n\nIf you want to disable ObjectId conversion for `_id:\n\n```\nvar users = db.collection('users', {\n\tObjectId: false\n});\n```\n\n## API\n\n###Top Level\n* `mongodb` - raw mongodb driver\n\n###Collection\n[MongoDB Collection](http://mongodb.github.io/node-mongodb-native/api-generated/collection.html)\n[MongoDB Queries](http://mongodb.github.io/node-mongodb-native/markdown-docs/queries.html)\n\n* `find([query][, fields][, options])`\n* `findOne([query][, fields][, options])`\n* `findById(oid[, fields][, options])`\n* `insert(docs[, options])`\n* `update(query, document[, options])`\n* `updateById(oid, document[, options])`\n* `remove([query][, options])`\n* `removeById(oid[, options])`\n* `count([query][, options])`\n* `save([doc][, options])`\n* `findAndModify(query, sort, doc[, options])`\n* `findAndRemove(query, sort[, options])`\n* `group(keys, condition, initial, reduce, finalize, command[, options])`\n* `aggregate(array[, options])`\n* `drop()`\n* `rename(newName[, options])`\n* `createIndex(fieldOrSpec[, options])`\n* `ensureIndex(fieldOrSpec[, options])`\n* `dropIndex(name)`\n\n###Db\n[MongoDB Db](http://mongodb.github.io/node-mongodb-native/api-generated/db.html)\n\n* `close()`\n* `admin()`\n* `collectionNames([collectionName][, options])`\n* `collections()`\n* `eval(code[, parameters][, options])`\n* `logout()`\n* `authenticate(username, password[, options])`\n* `addUser(username, password[, options])`\n* `removeUser(username[, options])`\n* `createCollection(collectionName[, options])`\n* `dropCollection(collectionName)`\n* `renameCollection(fromCollection, toCollection[, options])`\n* `dropDatabase()`\n* `stats([, options])`\n\n##TODO\n\n* Write some tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpradel%2Fmongodb-bluebird","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpradel%2Fmongodb-bluebird","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpradel%2Fmongodb-bluebird/lists"}