{"_id":"@elmarburke/gatsby-source-mongodb","_rev":"1-a85b39e9cf072fe074b8a365229fddc8","name":"@elmarburke/gatsby-source-mongodb","dist-tags":{"latest":"2.0.20"},"versions":{"2.0.20":{"name":"@elmarburke/gatsby-source-mongodb","description":"Source plugin for pulling data into Gatsby from MongoDB collections","version":"2.0.20","author":{"name":"jhermans85@hotmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"dependencies":{"@babel/runtime":"^7.0.0","lodash.camelcase":"^4.3.0","lodash.isstring":"^4.0.1","mongodb":"^3.1.13","query-string":"^6.1.0"},"devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","babel-preset-gatsby-package":"^0.1.4","cross-env":"^5.1.4"},"homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-mongodb#readme","keywords":["gatsby","gatsby-plugin"],"license":"MIT","main":"index.js","peerDependencies":{"gatsby":"^2.0.15"},"repository":{"type":"git","url":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-mongodb"},"scripts":{"build":"babel src --out-dir . --ignore **/__tests__","prepare":"cross-env NODE_ENV=production npm run build","watch":"babel -w src --out-dir . --ignore **/__tests__"},"_id":"@elmarburke/gatsby-source-mongodb@2.0.20","dist":{"shasum":"f472a80fa51f6d8b73f6a300f25cdfa95bf52853","integrity":"sha512-0uNnSFtmIq6I9v6wVB7Azxm6KVD0aw3OJONOFWMBxHE7SkRLyrAr9ZKcY0wyI4EX/zjnyFwUizXN1wWUJKbN/g==","tarball":"https://registry.npmjs.org/@elmarburke/gatsby-source-mongodb/-/gatsby-source-mongodb-2.0.20.tgz","fileCount":10,"unpackedSize":21427,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc753xCRA9TVsSAnZWagAA2CcP/iPBv+Z7Mssi+1PHe2e6\nN6choCQiuld8RkwXJ2600YpOjhhQjYVXVHQQK4WVfK2HhTL+AU2nmdla69OP\nQK8nkQiPvkWxzI7zBQt733/lHO6vF7R1PojGL8utjdFyk3EEqydXAyX759tA\nnIpbS7AZNfDoTApPLX7NcJS1sLoYstWd2oYskwd0Pld0/xe4zIpZsT7bBcrR\nazGagd7u+dDCBP1t980l8gTFzMzX3SpQTZarA9j+0gaz15lu5/rKYoxJLc/F\numPzz9wmhL1sB5p/tQ9rqntRj1a+zO88w+bS2zAokxOZw3GPlKF8vgWCDRtn\nMVjGtdt7nILxM+ftkfEg5lhO1BvDriG7rGTYMMA1Scn0AeyfkEpitvyk1BuC\ncCOqRGovifID9rbcl68Dy7xIdC8lN8W3ioWHquEiV+vFfi4+Bcjp3xkNhozo\nbA12UDw7yigPwzySf1hWljZ3tUOIFvr6Gq8ZRexpMgW0W+7uPQzMdl9ZUf8t\nova4fUo656nPXUS3wtbDNU4r+al3jr0DETYydJebIop1/KV8vboUfpRyzlq9\nUGblIt8dfnNMl9X+SlkQrlkxR4jhUbBIgRu9XYy1EdMH8GYY7O3ssf6yNtwV\nuKPn/HLQM0oRVehkAt/iZPj5+NPU4a7tVbZVVcu/BGb+OjwgFIbC6S5kt0yN\nT+zJ\r\n=u5Vo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHBzddjVHjsVBqu6Ss3cwE/diKvPiJwAJlLhhexFP3ggIgQO7EWUOt+afsfJjikuPmMVazNAoLF/uAV28tf062+cU="}]},"maintainers":[{"name":"elmarburke","email":"elmar@blendle.com"}],"_npmUser":{"name":"elmarburke","email":"elmar@blendle.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-source-mongodb_2.0.20_1559207408964_0.7468660473589623"},"_hasShrinkwrap":false}},"time":{"created":"2019-05-30T09:10:08.924Z","2.0.20":"2019-05-30T09:10:09.251Z","modified":"2022-04-05T07:22:03.665Z"},"maintainers":[{"name":"elmarburke","email":"elmar@blendle.com"}],"description":"Source plugin for pulling data into Gatsby from MongoDB collections","homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-mongodb#readme","keywords":["gatsby","gatsby-plugin"],"repository":{"type":"git","url":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-mongodb"},"author":{"name":"jhermans85@hotmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"license":"MIT","readme":"# gatsby-source-mongodb\n\nSource plugin for pulling data into Gatsby from MongoDB collections.\n\n## How to use\n\n```javascript\n// In your gatsby-config.js\nmodule.exports = {\n  plugins: [\n    /*\n     * Gatsby's data processing layer begins with “source” plugins. Here we\n     * setup the site to pull data from the \"documents\" collection in a local\n     * MongoDB instance\n     */\n    {\n      resolve: `gatsby-source-mongodb`,\n      options: { dbName: `local`, collection: `documents` },\n    },\n  ],\n}\n```\n\n### multiple collections\n\n```javascript\n// In your gatsby-config.js\nmodule.exports = {\n  plugins: [\n    {\n      resolve: `gatsby-source-mongodb`,\n      options: { dbName: `local`, collection: [`documents`, `vehicles`] },\n    },\n  ],\n}\n```\n\n## Plugin options\n\n- **connectionString**: if you need to use a connection string compatable with later versions of MongoDB, or for connections to MongoDB Atlas, you can enter the entire string, minus the `dbName` and `extraParams.` Use the In this case, the authentication information should already be embedded in the string ex. `mongodb+srv://<USERNAME>:<PASSWORD>@<SERVERNANE>-fsokc.mongodb.net`. Pass `dbName` and `extraParams` as options per below.\n- **dbName**: indicates the database name that you want to use\n- **collection**: the collection name within Mongodb, this can also be an array\n  for multiple collections\n- **server**: contains the server info, with sub properties address and port ex.\n  server: { address: `ds143532.mlab.com`, port: 43532 }. Defaults to a server\n  running locally on the default port.\n- **auth**: the authentication data to login a Mongodb collection, with sub\n  properties user and password. ex. auth: { user: `admin`, password: `12345` }\n- **extraParams**: useful to set additional parameters for the connection, like authSource, ssl or replicaSet\n  (needed for connecting to MongoDB Atlas db as a service), ex: extraParams: { replicaSet: `test-shard-0`, ssl: `true`, authSource: `admin` }. These are the types of options that can be appended as query parameters to the connection URI: https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options\n- **clientOptions**: for setting options on the creation of a `MongoClient` instance. By default to handle the various connection URI's necessary for newer versions of MongoDB Atlas, for instance, we pass { `useNewUrlParser`: `true` }. You can override the default by passing either an empty object literal or filled with other valid connection options. All options [specified in the `MongoClient` documentation](http://mongodb.github.io/node-mongodb-native/3.1/reference/connecting/connection-settings/) are valid for usage.\n- **preserveObjectIds**: for preserving nested ObjectIDs within documents, set this to the Boolean `true`, ex: preserveObjectIds: `true`.\n\n### Mapping mediatype feature\n\nGatsby supports transformer plugins that know how to transform one data type to\nanother e.g. markdown to html. In the plugin options you can setup \"mappings\"\nfor fields in your collections. You can tell Gatsby that a certain field is a\ngiven media type and with the correct transformer plugins installed, your data\nwill be transformed automatically.\n\nLet's say we have a markdown field named `body` in our mongoDB collection\n`documents`. We want to author our content in markdown but want to transform the\nmarkdown to HTML for including in our React components.\n\nTo do this, we modify the plugin configuration in `gatsby-config.js` like\nfollows:\n\n```javascript\nmodule.exports = {\n  plugins: [\n    {\n      resolve: `gatsby-source-mongodb`,\n      options: {\n        dbName: `local`,\n        collection: `documents`\n        // highlight-start\n        map: {\n          {documents: {body: `text/markdown`}\n        },\n        // highlight-end\n      },\n    }\n  ],\n}\n```\n\nThe GraphQL query to get the transformed markdown would look something like\nthis.\n\n```graphql\nquery($id: String!) {\n  mongodbCloudDocuments(id: { eq: $id }) {\n    id\n    name\n    url\n    body {\n      childMarkdownRemark {\n        id\n        html\n      }\n    }\n  }\n}\n```\n\n## How to query your MongoDB data using GraphQL\n\nBelow is a sample query for fetching all MongoDB document nodes from a db named\n**'Cloud'** and a collection named **'documents'**.\n\n```graphql\nquery {\n  allMongodbCloudDocuments {\n    edges {\n      node {\n        id\n        url\n        name\n      }\n    }\n  }\n}\n```\n","readmeFilename":"README.md"}