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

cypress-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-mongodb - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

10

dist/commands/aggregation.js

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.aggregate = void 0;
function aggregate(pipeline, database, collection) {
var args = {
export function aggregate(pipeline, database, collection) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -28,6 +25,5 @@ database: Cypress.env('MONGODB_DATABASE'),

pipeline: pipeline
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.aggregate = aggregate;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dropCollection = exports.createCollection = void 0;
function createCollection(collection, database) {
var args = {
export function createCollection(collection, database) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -24,9 +21,8 @@ database: Cypress.env('MONGODB_DATABASE'),

database: args.database,
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.createCollection = createCollection;
function dropCollection(collection, database) {
var args = {
export function dropCollection(collection, database) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -51,6 +47,5 @@ database: Cypress.env('MONGODB_DATABASE'),

database: args.database,
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.dropCollection = dropCollection;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteMany = exports.deleteOne = void 0;
function deleteOne(pipeline, collection, database) {
var args = {
export function deleteOne(pipeline, collection, database) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -31,9 +28,8 @@ database: Cypress.env('MONGODB_DATABASE'),

database: args.database,
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.deleteOne = deleteOne;
function deleteMany(pipeline, collection, database) {
var args = {
export function deleteMany(pipeline, collection, database) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -64,6 +60,5 @@ database: Cypress.env('MONGODB_DATABASE'),

database: args.database,
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.deleteMany = deleteMany;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.insertMany = exports.insertOne = void 0;
function insertOne(pipeline, collection, database) {
var args = {
export function insertOne(pipeline, collection, database) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -31,9 +28,8 @@ database: Cypress.env('MONGODB_DATABASE'),

database: args.database,
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.insertOne = insertOne;
function insertMany(pipeline, collection, database) {
var args = {
export function insertMany(pipeline, collection, database) {
let args = {
uri: Cypress.env('MONGODB_URI'),

@@ -64,6 +60,5 @@ database: Cypress.env('MONGODB_DATABASE'),

database: args.database,
}).then(function (result) {
}).then((result) => {
return result;
});
}
exports.insertMany = insertMany;

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,107 +10,70 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupMongoDB = exports.setConfig = void 0;
var aggregate_util = require("./utils/aggregation");
var aggregate_commands = require("./commands/aggregation");
var collection_util = require("./utils/collection");
var collection_commands = require("./commands/collection");
var insert_util = require("./utils/insert");
var insert_commands = require("./commands/insert");
var delete_util = require("./utils/delete");
var delete_commands = require("./commands/delete");
var setConfig = function (on) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
on('task', {
aggregate: function (args) {
return aggregate_util.aggregate(args).then(function (result) {
return result;
});
},
});
on('task', {
createCollection: function (args) {
return collection_util.createCollection(args).then(function (result) {
return result;
});
},
});
on('task', {
dropCollection: function (args) {
return collection_util.dropCollection(args).then(function (result) {
return result;
});
},
});
on('task', {
insertOne: function (args) {
return insert_util.insertOne(args).then(function (result) {
return result;
});
},
});
on('task', {
insertMany: function (args) {
return insert_util.insertMany(args).then(function (result) {
return result;
});
},
});
on('task', {
deleteOne: function (args) {
return delete_util.deleteOne(args).then(function (result) {
return result;
});
},
});
on('task', {
deleteMany: function (args) {
return delete_util.deleteMany(args).then(function (result) {
return result;
});
},
});
return [2];
import * as aggregate_util from "./utils/aggregation";
import * as aggregate_commands from './commands/aggregation';
import * as collection_util from "./utils/collection";
import * as collection_commands from './commands/collection';
import * as insert_util from "./utils/insert";
import * as insert_commands from './commands/insert';
import * as delete_util from "./utils/delete";
import * as delete_commands from './commands/delete';
export const setConfig = (on) => __awaiter(void 0, void 0, void 0, function* () {
on('task', {
aggregate(args) {
return aggregate_util.aggregate(args).then(result => {
return result;
});
},
});
}); };
exports.setConfig = setConfig;
var setupMongoDB = function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
Cypress.Commands.add('aggregate', aggregate_commands.aggregate);
Cypress.Commands.add('createCollection', collection_commands.createCollection);
Cypress.Commands.add('dropCollection', collection_commands.dropCollection);
Cypress.Commands.add('insertOne', insert_commands.insertOne);
Cypress.Commands.add('insertMany', insert_commands.insertMany);
Cypress.Commands.add('deleteOne', delete_commands.deleteOne);
Cypress.Commands.add('deleteMany', delete_commands.deleteMany);
console.log('MongoDB plugin configured');
return [2];
on('task', {
createCollection(args) {
return collection_util.createCollection(args).then(result => {
return result;
});
},
});
}); };
exports.setupMongoDB = setupMongoDB;
on('task', {
dropCollection(args) {
return collection_util.dropCollection(args).then(result => {
return result;
});
},
});
on('task', {
insertOne(args) {
return insert_util.insertOne(args).then(result => {
return result;
});
},
});
on('task', {
insertMany(args) {
return insert_util.insertMany(args).then(result => {
return result;
});
},
});
on('task', {
deleteOne(args) {
return delete_util.deleteOne(args).then(result => {
return result;
});
},
});
on('task', {
deleteMany(args) {
return delete_util.deleteMany(args).then(result => {
return result;
});
},
});
});
export const setupMongoDB = () => __awaiter(void 0, void 0, void 0, function* () {
Cypress.Commands.add('aggregate', aggregate_commands.aggregate);
Cypress.Commands.add('createCollection', collection_commands.createCollection);
Cypress.Commands.add('dropCollection', collection_commands.dropCollection);
Cypress.Commands.add('insertOne', insert_commands.insertOne);
Cypress.Commands.add('insertMany', insert_commands.insertMany);
Cypress.Commands.add('deleteOne', delete_commands.deleteOne);
Cypress.Commands.add('deleteMany', delete_commands.deleteMany);
console.log('MongoDB plugin configured');
});

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,68 +10,26 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.aggregate = void 0;
var mongodb_1 = require("mongodb");
function aggregate(args) {
return __awaiter(this, void 0, void 0, function () {
var client, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
client = new mongodb_1.MongoClient(args.uri);
return [4, client.connect()];
case 1:
_a.sent();
_a.label = 2;
case 2:
_a.trys.push([2, 4, 5, 7]);
return [4, client.db(args.database).collection(args.collection).aggregate(args.pipeline).toArray()];
case 3: return [2, _a.sent()];
case 4:
err_1 = _a.sent();
throw new Error('Error connecting: ' + err_1.stack);
case 5: return [4, client.close()];
case 6:
_a.sent();
return [7];
case 7: return [2];
}
});
import { MongoClient } from "mongodb";
export function aggregate(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
const client = new MongoClient(args.uri);
yield client.connect();
try {
return yield client.db(args.database).collection(args.collection).aggregate(args.pipeline).toArray();
}
catch (err) {
throw new Error('Error connecting: ' + err.stack);
}
finally {
yield client.close();
}
});
}
exports.aggregate = aggregate;

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,81 +10,46 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.dropCollection = exports.createCollection = void 0;
var mongodb_1 = require("mongodb");
function createCollection(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).createCollection(args.collection).then(function (res) {
client.close();
return 'Collection created';
}).catch(function (err) {
client.close();
throw err;
});
})];
import { MongoClient } from "mongodb";
export function createCollection(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
return MongoClient.connect(args.uri).then(client => {
return client.db(args.database).createCollection(args.collection).then(res => {
client.close();
return 'Collection created';
}).catch(err => {
client.close();
throw err;
});
});
});
}
exports.createCollection = createCollection;
function dropCollection(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).drop().then(function (res) {
client.close();
return 'Collection dropped';
}).catch(function (err) {
client.close();
throw err;
});
})];
export function dropCollection(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
return MongoClient.connect(args.uri).then(client => {
return client.db(args.database).collection(args.collection).drop().then(res => {
client.close();
return 'Collection dropped';
}).catch(err => {
client.close();
throw err;
});
});
});
}
exports.dropCollection = dropCollection;

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,87 +10,52 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteMany = exports.deleteOne = void 0;
var mongodb_1 = require("mongodb");
function deleteOne(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).deleteOne(args.pipeline).then(function (res) {
client.close();
return res.deletedCount + ' document deleted';
}).catch(function (err) {
client.close();
throw err;
});
})];
import { MongoClient } from "mongodb";
export function deleteOne(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return MongoClient.connect(args.uri).then(client => {
return client.db(args.database).collection(args.collection).deleteOne(args.pipeline).then(res => {
client.close();
return res.deletedCount + ' document deleted';
}).catch(err => {
client.close();
throw err;
});
});
});
}
exports.deleteOne = deleteOne;
function deleteMany(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).deleteMany(args.pipeline).then(function (res) {
client.close();
return res.deletedCount + ' documents deleted';
}).catch(function (err) {
client.close();
throw err;
});
})];
export function deleteMany(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return MongoClient.connect(args.uri).then(client => {
return client.db(args.database).collection(args.collection).deleteMany(args.pipeline).then(res => {
client.close();
return res.deletedCount + ' documents deleted';
}).catch(err => {
client.close();
throw err;
});
});
});
}
exports.deleteMany = deleteMany;

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,87 +10,52 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.insertMany = exports.insertOne = void 0;
var mongodb_1 = require("mongodb");
function insertOne(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).insertOne(args.pipeline).then(function (res) {
client.close();
return '1 document inserted: ' + res.insertedId;
}).catch(function (err) {
client.close();
throw err;
});
})];
import { MongoClient } from "mongodb";
export function insertOne(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return MongoClient.connect(args.uri).then(client => {
return client.db(args.database).collection(args.collection).insertOne(args.pipeline).then(res => {
client.close();
return '1 document inserted: ' + res.insertedId;
}).catch(err => {
client.close();
throw err;
});
});
});
}
exports.insertOne = insertOne;
function insertMany(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || !Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an array');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).insertMany(args.pipeline).then(function (res) {
client.close();
return res.insertedCount + ' documents inserted';
}).catch(function (err) {
client.close();
throw err;
});
})];
export function insertMany(args) {
return __awaiter(this, void 0, void 0, function* () {
if (!args.uri) {
throw new Error('Missing MONGODB_URI environment variable');
}
else if (!args.database) {
throw new Error('Database not specified');
}
else if (!args.collection) {
throw new Error('Collection not specified');
}
else if (!args.pipeline || !Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an array');
}
return MongoClient.connect(args.uri).then(client => {
return client.db(args.database).collection(args.collection).insertMany(args.pipeline).then(res => {
client.close();
return res.insertedCount + ' documents inserted';
}).catch(err => {
client.close();
throw err;
});
});
});
}
exports.insertMany = insertMany;
{
"name": "cypress-mongodb",
"version": "1.0.4",
"version": "1.1.0",
"description": "Cypress MongoDB plugin",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"scripts": {

@@ -8,0 +9,0 @@ "test": "mocha ./dist/test/*.spec.js",

@@ -64,3 +64,3 @@ # Introduction

In your `cypress/index/index.js` add the following:
In your `cypress/support/index.js` add the following:

@@ -89,3 +89,3 @@ ```

In your `cypress/index/index.ts` add the following:
In your `cypress/support/index.ts` add the following:

@@ -92,0 +92,0 @@ ```

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