New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-source-mongodb

Package Overview
Dependencies
Maintainers
2
Versions
366
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-mongodb - npm Package Compare versions

Comparing version 1.6.0-alpha.f5c1df61 to 2.1.0-alpha.53bbd4cd

79

gatsby-node.js

@@ -1,29 +0,23 @@

"use strict";
const MongoClient = require(`mongodb`).MongoClient;
var _extends2 = require("babel-runtime/helpers/extends");
const crypto = require(`crypto`);
var _extends3 = _interopRequireDefault(_extends2);
const createMappingChildNodes = require(`./mapping`);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const _ = require(`lodash`);
var MongoClient = require(`mongodb`).MongoClient;
var crypto = require(`crypto`);
var createMappingChildNodes = require(`./mapping`);
var _ = require(`lodash`);
exports.sourceNodes = function (_ref, pluginOptions, done) {
var actions = _ref.actions,
getNode = _ref.getNode,
hasNodeChanged = _ref.hasNodeChanged;
var createNode = actions.createNode;
var serverOptions = pluginOptions.server || {
exports.sourceNodes = ({
actions,
getNode,
createNodeId,
hasNodeChanged
}, pluginOptions, done) => {
const createNode = actions.createNode;
let serverOptions = pluginOptions.server || {
address: `localhost`,
port: 27017
};
var dbName = pluginOptions.dbName || `local`,
let dbName = pluginOptions.dbName || `local`,
authUrlPart = ``;
if (pluginOptions.auth) authUrlPart = `${pluginOptions.auth.user}:${pluginOptions.auth.password}@`;
MongoClient.connect(`mongodb://${authUrlPart}${serverOptions.address}:${serverOptions.port}/${dbName}`, function (err, db) {

@@ -35,22 +29,23 @@ // Establish connection to db

}
var collection = pluginOptions.collection || `documents`;
let collection = pluginOptions.collection || `documents`;
if (_.isArray(collection)) {
for (var _iterator = collection, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref2;
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
_ref = _i.value;
}
var col = _ref2;
createNodes(db, pluginOptions, dbName, createNode, col, done);
const col = _ref;
createNodes(db, pluginOptions, dbName, createNode, createNodeId, col, done);
}
} else {
createNodes(db, pluginOptions, dbName, createNode, collection, done);
createNodes(db, pluginOptions, dbName, createNode, createNodeId, collection, done);
}

@@ -60,7 +55,6 @@ });

function createNodes(db, pluginOptions, dbName, createNode, collectionName, done) {
var collection = db.collection(collectionName);
var cursor = collection.find();
function createNodes(db, pluginOptions, dbName, createNode, createNodeId, collectionName, done) {
let collection = db.collection(collectionName);
let cursor = collection.find(); // Execute the each command, triggers for each document
// Execute the each command, triggers for each document
cursor.each(function (err, item) {

@@ -74,6 +68,6 @@ // If the item is null then the cursor is exhausted/empty and closed

var id = item._id.toString();
delete item._id;
var node = (0, _extends3.default)({}, item, {
id: `${id}`,
var node = Object.assign({}, item, {
id: createNodeId(`${id}`),
parent: `__${collectionName}__`,

@@ -87,12 +81,14 @@ children: [],

});
if (pluginOptions.map) {
var mapObj = pluginOptions.map;
let mapObj = pluginOptions.map;
if (pluginOptions.map[collectionName]) {
mapObj = pluginOptions.map[collectionName];
}
// We need to map certain fields to a contenttype.
Object.keys(mapObj).forEach(function (mediaItemFieldKey) {
} // We need to map certain fields to a contenttype.
Object.keys(mapObj).forEach(mediaItemFieldKey => {
if (node[mediaItemFieldKey] && (typeof mapObj[mediaItemFieldKey] === `string` || mapObj[mediaItemFieldKey] instanceof String)) {
node[`${mediaItemFieldKey}___NODE`] = createMappingChildNodes(node, mediaItemFieldKey, node[mediaItemFieldKey], mapObj[mediaItemFieldKey], createNode);
delete node[mediaItemFieldKey];

@@ -102,2 +98,3 @@ }

}
createNode(node);

@@ -109,5 +106,3 @@ }

function caps(s) {
return s.replace(/\b\w/g, function (l) {
return l.toUpperCase();
});
return s.replace(/\b\w/g, l => l.toUpperCase());
}

@@ -1,10 +0,8 @@

"use strict";
const _ = require(`lodash`),
crypto = require(`crypto`);
var _ = require(`lodash`),
crypto = require(`crypto`);
module.exports = function (node, key, text, mediaType, createNode) {
var str = _.isString(text) ? text : ` `;
var id = `${node.id}${key}MappingNode`;
var mappingNode = {
const str = _.isString(text) ? text : ` `;
const id = `${node.id}${key}MappingNode`;
const mappingNode = {
id: id,

@@ -21,7 +19,5 @@ parent: node.id,

};
node.children = node.children.concat([mappingNode.id]);
createNode(mappingNode);
return mappingNode.id;
};
{
"name": "gatsby-source-mongodb",
"version": "1.6.0-alpha.f5c1df61",
"version": "2.1.0-alpha.53bbd4cd",
"description": "Stub description for gatsby-source-mongodb",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__",
"build": "babel src --out-dir . --ignore **/__tests__/**",
"watch": "babel -w src --out-dir . --ignore **/__tests__/**",
"prepublish": "cross-env NODE_ENV=production npm run build"

@@ -17,7 +17,8 @@ },

"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.0.0-beta.38",
"lodash": "^4.17.4",

@@ -24,0 +25,0 @@ "mongodb": "^2.2.30"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc