Huge News!Announcing our $40M Series B led by Abstract Ventures.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 5.4.0 to 5.5.0

3

dist/commands/aggregation.d.ts
/// <reference types="node" />
import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
import { MongoOptions } from '../index';
export declare function aggregate(pipeline: Document[] | Buffer, options: MongoOptions | undefined): Chainable;
export declare function aggregate(pipeline: Document[] | Buffer, options?: any): Chainable;

@@ -9,6 +9,5 @@ "use strict";

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
pipeline: pipeline,

@@ -15,0 +14,0 @@ };

import Chainable = Cypress.Chainable;
export declare function createCollection(collection: string, options?: {
database?: string;
failSilently?: boolean;
}): Chainable;
export declare function dropCollection(collection: string, options?: {
database?: string;
failSilently?: boolean;
}): Chainable;
export declare function createCollection(collection: string, options?: any): Chainable;
export declare function dropCollection(collection: string, options?: any): Chainable;

@@ -6,10 +6,7 @@ "use strict";

function createCollection(collection, options) {
var _a;
var args = {
uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: collection,
failSilently: (_a = options === null || options === void 0 ? void 0 : options.failSilently) !== null && _a !== void 0 ? _a : false,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: collection,
options: options,
};

@@ -23,10 +20,7 @@ (0, validator_1.validate)(args);

function dropCollection(collection, options) {
var _a;
var args = {
uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: collection,
failSilently: (_a = options === null || options === void 0 ? void 0 : options.failSilently) !== null && _a !== void 0 ? _a : false,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: collection,
options: options,
};

@@ -33,0 +27,0 @@ (0, validator_1.validate)(args);

import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
import { MongoOptions } from '../index';
export declare function deleteOne(filter: Document, options: MongoOptions | undefined): Chainable;
export declare function deleteMany(filter: Document, options: MongoOptions | undefined): Chainable;
export declare function deleteOne(filter: Document, options?: any): Chainable;
export declare function deleteMany(filter: Document, options?: any): Chainable;

@@ -9,6 +9,5 @@ "use strict";

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
filter: filter,

@@ -32,6 +31,5 @@ };

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
filter: filter,

@@ -38,0 +36,0 @@ };

import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
import { MongoOptions } from '../index';
export declare function findOne(query: Document, options?: MongoOptions): Chainable;
export declare function findOneAndUpdate(filter: Document, document: Document, options?: {
database?: string;
collection?: string;
upsert?: boolean;
returnDocument?: 'before' | 'after';
}): Chainable;
export declare function findOneAndDelete(filter: Document, options?: {
database?: string;
collection?: string;
sort?: Document;
projection?: Document;
}): Chainable;
export declare function findMany(query: Document, options: MongoOptions | undefined): Chainable;
export declare function findOne(query: Document, options?: any): Chainable;
export declare function findOneAndUpdate(filter: Document, document: Document, options?: any): Chainable;
export declare function findOneAndDelete(filter: Document, options?: any): Chainable;
export declare function findMany(query: Document, options?: any): Chainable;

@@ -9,6 +9,5 @@ "use strict";

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
query: query,

@@ -35,8 +34,5 @@ };

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
upsert: options === null || options === void 0 ? void 0 : options.upsert,
returnDocument: options === null || options === void 0 ? void 0 : options.returnDocument,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
filter: filter,

@@ -71,8 +67,5 @@ document: document,

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
sort: options === null || options === void 0 ? void 0 : options.sort,
projection: options === null || options === void 0 ? void 0 : options.projection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
filter: filter,

@@ -88,4 +81,3 @@ };

args.filter = (0, bson_1.serialize)(args.filter);
args.options.sort = (0, bson_1.serialize)(args.options.sort);
args.options.projection = (0, bson_1.serialize)(args.options.projection);
args.options = (0, bson_1.serialize)(args.options);
return cy.task('findOneAndDelete', args).then(function (result) {

@@ -102,6 +94,5 @@ if (result !== null)

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
query: query,

@@ -108,0 +99,0 @@ };

import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
import { MongoOptions } from '../index';
export declare function insertOne(document: Document, options?: MongoOptions): Chainable;
export declare function insertMany(documents: Document[], options: MongoOptions | undefined): Chainable;
export declare function insertOne(document: Document, options?: any): Chainable;
export declare function insertMany(documents: Document[], options?: any): Chainable;

@@ -9,6 +9,5 @@ "use strict";

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
document: document,

@@ -32,6 +31,5 @@ };

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
documents: documents,

@@ -38,0 +36,0 @@ };

import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
import { MongoOptions } from '../index';
export declare function updateOne(filter: Document, document: Document, options?: MongoOptions): Chainable;
export declare function updateMany(filter: Document, document: Document, options: MongoOptions | undefined): Chainable;
export declare function updateOne(filter: Document, document: Document, options?: any): Chainable;
export declare function updateMany(filter: Document, document: Document, options?: any): Chainable;

@@ -9,7 +9,5 @@ "use strict";

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
upsert: options === null || options === void 0 ? void 0 : options.upsert,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
filter: filter,

@@ -41,7 +39,5 @@ document: document,

uri: Cypress.env('mongodb').uri,
options: {
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
upsert: options === null || options === void 0 ? void 0 : options.upsert,
},
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database,
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection,
options: options,
filter: filter,

@@ -48,0 +44,0 @@ document: document,

@@ -6,32 +6,19 @@ /// <reference types="cypress" />

interface Chainable<Subject> {
aggregate(pipeline: Document[], options?: MongoOptions): Chainable<Subject>;
createCollection(collection: string, options?: {
database?: string;
failSilently?: boolean;
}): Chainable<Subject>;
dropCollection(collection: string, options?: {
database?: string;
failSilently?: boolean;
}): Chainable<Subject>;
insertOne(document: Document, options?: MongoOptions): Chainable<Subject>;
insertMany(documents: Document[], options?: MongoOptions): Chainable<Subject>;
deleteOne(filter: Document, options?: MongoOptions): Chainable<Subject>;
deleteMany(filter: Document, options?: MongoOptions): Chainable<Subject>;
findOne(query: Document, options?: MongoOptions): Chainable<Subject>;
aggregate(pipeline: Document[], options?: any): Chainable<Subject>;
createCollection(collection: string, options?: any): Chainable<Subject>;
dropCollection(collection: string, options?: any): Chainable<Subject>;
insertOne(document: Document, options?: any): Chainable<Subject>;
insertMany(documents: Document[], options?: any): Chainable<Subject>;
deleteOne(filter: Document, options?: any): Chainable<Subject>;
deleteMany(filter: Document, options?: any): Chainable<Subject>;
findOne(query: Document, options?: any): Chainable<Subject>;
findOneAndUpdate(filter: Document, document: Document, options?: any): Chainable<Subject>;
findOneAndDelete(filter: Document, options?: MongoOptions): Chainable<Subject>;
findMany(query: Document, options?: MongoOptions): Chainable<Subject>;
updateOne(filter: Document, document: Document, options?: MongoOptions): Chainable<Subject>;
updateMany(filter: Document, document: Document, options?: MongoOptions): Chainable<Subject>;
findOneAndDelete(filter: Document, options?: any): Chainable<Subject>;
findMany(query: Document, options?: any): Chainable<Subject>;
updateOne(filter: Document, document: Document, options?: any): Chainable<Subject>;
updateMany(filter: Document, document: Document, options?: any): Chainable<Subject>;
}
}
}
export interface MongoOptions {
collection?: string;
database?: string;
failSilently?: boolean;
upsert?: boolean;
returnDocument?: string;
}
export declare function configurePlugin(on: Cypress.PluginEvents): void;
export declare function addCommands(): void;

@@ -58,5 +58,5 @@ "use strict";

return [4, client
.db(args.options.database)
.collection(args.options.collection)
.aggregate(args.pipeline)
.db(args.database)
.collection(args.collection)
.aggregate(args.pipeline, args.options)
.toArray()];

@@ -63,0 +63,0 @@ case 3:

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

export declare function createCollection(args: any): Promise<any>;
export declare function dropCollection(args: any): Promise<any>;
export declare function createCollection(args: any): Promise<unknown>;
export declare function dropCollection(args: any): Promise<unknown>;

@@ -42,51 +42,68 @@ "use strict";

function createCollection(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client
.db(args.options.database)
.createCollection(args.options.collection)
.then(function () {
client.close();
return 'Collection created';
})
.catch(function (err) {
client.close();
if (args.options.failSilently) {
return err;
}
else {
throw err;
}
});
})];
var _this = this;
return mongodb_1.MongoClient.connect(args.uri).then(function (client) { return __awaiter(_this, void 0, void 0, function () {
var database, failSilently, result, error_1;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
database = client.db(args.database);
failSilently = (_a = args.options) === null || _a === void 0 ? void 0 : _a.failSilently;
if (args.options) {
delete args.options.database;
delete args.options.failSilently;
}
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4, database.createCollection(args.collection, args.options)];
case 2:
result = _b.sent();
client.close();
return [2, 'Collection created'];
case 3:
error_1 = _b.sent();
if (failSilently)
return [2, error_1];
else
throw error_1;
return [3, 4];
case 4: return [2];
}
});
});
}); });
}
exports.createCollection = createCollection;
function dropCollection(args) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client
.db(args.options.database)
.collection(args.options.collection)
.drop()
.then(function () {
client.close();
return 'Collection dropped';
})
.catch(function (err) {
client.close();
if (args.options.failSilently) {
return err;
}
else {
throw err;
}
});
})];
var _this = this;
return mongodb_1.MongoClient.connect(args.uri).then(function (client) { return __awaiter(_this, void 0, void 0, function () {
var database, failSilently, result, error_2;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
database = client.db(args.database);
failSilently = (_a = args.options) === null || _a === void 0 ? void 0 : _a.failSilently;
if (args.options)
delete args.options.failSilently;
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4, database.dropCollection(args.collection, args.options)];
case 2:
result = _b.sent();
client.close();
return [2, 'Collection dropped'];
case 3:
error_2 = _b.sent();
if (failSilently)
return [2, error_2];
else
throw error_2;
return [3, 4];
case 4: return [2];
}
});
});
}); });
}
exports.dropCollection = dropCollection;

@@ -43,44 +43,42 @@ "use strict";

function deleteOne(args) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
args.filter = (0, bson_1.deserialize)(Buffer.from(args.filter));
return mongodb_1.MongoClient.connect(args.uri).then(function (client) { return __awaiter(_this, void 0, void 0, function () {
var collection, result;
return __generator(this, function (_a) {
args.filter = (0, bson_1.deserialize)(Buffer.from(args.filter));
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client
.db(args.options.database)
.collection(args.options.collection)
.deleteOne(args.filter)
.then(function (res) {
client.close();
return res.deletedCount + ' document deleted';
})
.catch(function (err) {
client.close();
throw err;
});
})];
switch (_a.label) {
case 0:
collection = client
.db(args.database)
.collection(args.collection);
return [4, collection.deleteOne(args.filter, args.options)];
case 1:
result = _a.sent();
client.close();
return [2, result.deletedCount + ' document deleted'];
}
});
});
}); });
}
exports.deleteOne = deleteOne;
function deleteMany(args) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
args.filter = (0, bson_1.deserialize)(Buffer.from(args.filter));
return mongodb_1.MongoClient.connect(args.uri).then(function (client) { return __awaiter(_this, void 0, void 0, function () {
var collection, result;
return __generator(this, function (_a) {
args.filter = (0, bson_1.deserialize)(Buffer.from(args.filter));
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client
.db(args.options.database)
.collection(args.options.collection)
.deleteMany(args.filter)
.then(function (result) {
client.close();
return result.deletedCount + ' documents deleted';
})
.catch(function (err) {
client.close();
throw err;
});
})];
switch (_a.label) {
case 0:
collection = client
.db(args.database)
.collection(args.collection);
return [4, collection.deleteMany(args.filter, args.options)];
case 1:
result = _a.sent();
client.close();
return [2, result.deletedCount + ' documents deleted'];
}
});
});
}); });
}
exports.deleteMany = deleteMany;

@@ -54,5 +54,5 @@ "use strict";

return [4, client
.db(args.options.database)
.collection(args.options.collection)
.findOne(args.query)];
.db(args.database)
.collection(args.collection)
.findOne(args.query, args.options)];
case 1:

@@ -93,4 +93,4 @@ result = _a.sent();

return [4, client
.db(args.options.database)
.collection(args.options.collection)
.db(args.database)
.collection(args.collection)
.findOneAndUpdate(args.filter, args.document, args.options)];

@@ -124,4 +124,3 @@ case 1:

args.filter = (0, bson_1.deserialize)(Buffer.from(args.filter));
args.options.sort = (0, bson_1.deserialize)(Buffer.from(args.options.sort));
args.options.projection = (0, bson_1.deserialize)(Buffer.from(args.options.projection));
args.options = (0, bson_1.deserialize)(Buffer.from(args.options));
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { return __awaiter(_this, void 0, void 0, function () {

@@ -134,4 +133,4 @@ var result, err_3;

return [4, client
.db(args.options.database)
.collection(args.options.collection)
.db(args.database)
.collection(args.collection)
.findOneAndDelete(args.filter, args.options)];

@@ -166,5 +165,5 @@ case 1:

return client
.db(args.options.database)
.collection(args.options.collection)
.find(args.query)
.db(args.database)
.collection(args.collection)
.find(args.query, args.options)
.toArray()

@@ -171,0 +170,0 @@ .then(function (result) {

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

export declare function insertOne(args: any): Promise<import("bson").ObjectID>;
export declare function insertMany(args: any): Promise<{
[key: number]: import("bson").ObjectID;
}>;
export declare function insertOne(args: any): Promise<any>;
export declare function insertMany(args: any): Promise<any>;

@@ -54,5 +54,5 @@ "use strict";

return [4, client
.db(args.options.database)
.collection(args.options.collection)
.insertOne(args.document)];
.db(args.database)
.collection(args.collection)
.insertOne(args.document, args.options)];
case 1:

@@ -80,19 +80,20 @@ res = _a.sent();

return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
args.documents = (0, bson_1.deserialize)(Buffer.from(args.documents));
args.documents = Object.values(args.documents);
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client
.db(args.options.database)
.collection(args.options.collection)
.insertMany(args.documents)
.then(function (result) {
client.close();
return result.insertedIds;
})
.catch(function (err) {
client.close();
throw err;
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { return __awaiter(_this, void 0, void 0, function () {
var collection, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
collection = client.db(args.database).collection(args.collection);
return [4, collection.insertMany(args.documents, args.options)];
case 1:
result = _a.sent();
client.close();
return [2, result.insertedIds];
}
});
})];
}); })];
});

@@ -99,0 +100,0 @@ });

@@ -55,4 +55,4 @@ "use strict";

return [4, client
.db(args.options.database)
.collection(args.options.collection)
.db(args.database)
.collection(args.collection)
.updateOne(args.filter, args.document, args.options)];

@@ -91,4 +91,4 @@ case 1:

_a.trys.push([0, 3, , 5]);
database = client.db(args.options.database);
collection = database.collection(args.options.collection);
database = client.db(args.database);
collection = database.collection(args.collection);
return [4, collection.updateMany(args.filter, args.document, args.options)];

@@ -95,0 +95,0 @@ case 1:

@@ -8,6 +8,6 @@ "use strict";

}
if (!args.options.collection) {
if (!args.collection) {
throw new Error('Collection not specified');
}
if (!args.options.database) {
if (!args.database) {
throw new Error('Database not specified');

@@ -14,0 +14,0 @@ }

{
"name": "cypress-mongodb",
"version": "5.4.0",
"version": "5.5.0",
"description": "Cypress MongoDB plugin",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -102,22 +102,15 @@ # Introduction

```TypeScript
cy.createCollection(collectionName);
cy.createCollection(collectionName, options);
cy.createCollection(name);
cy.createCollection(name, options);
cy.dropCollection(collectionName);
cy.dropCollection(collectionName, options);
cy.dropCollection(name);
cy.dropCollection(name, options);
```
### > arguments
| Arguments | Type | Description |
|----------------|-------------------|----------------------------------------|
| collectionName | String (required) | Name of the collection to create/drop |
| options | Object (optional) | Provide additional options (see below) |
| Arguments | Type | Description |
|-----------|-------------------|----------------------------------------|
| name | String (required) | Name of the collection to create/drop |
| options | Object (optional) | Provide additional options (see below) |
### > options
| Options | Default | Description |
|--------------|-------------------------------------------------------|--------------------------------------------------------------------|
| database | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| failSilently | `false` | Control if the command will fail or if the collection is not found |
### > examples

@@ -155,9 +148,2 @@ ```TypeScript

### > options
| Options | Default | Description |
|--------------|-------------------------------------------------------|---------------------------------------------------------|
| collection | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| database | Value specified in the `mongodb` environment variable | Collection on top of which the command will be executed |
### > examples

@@ -201,13 +187,2 @@ ```TypeScript

### > options
| Options | Default | Description |
|----------------|-------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| collection | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| database | Value specified in the `mongodb` environment variable | Collection on top of which the command will be executed |
| upsert | `false` | Creates a new document if no documents matched the provided filter (used only in `findOneAndUpdate` command) |
| returnDocument | `before` | Specify this option with `after` value to return the update document instead of the original one (used only in `findOneAndUpdate` command) |
| sort | First matching document | Specifies a sorting order for the documents matched by the filter (used only in `findOneAndDelete` command) |
| projection | Entire document | A subset of fields to return (used only in `findOneAndDelete` command) |
### > examples

@@ -249,10 +224,2 @@ ```TypeScript

### > options
| Options | Default | Description |
|------------|-------------------------------------------------------|---------------------------------------------------------------------------|
| collection | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| database | Value specified in the `mongodb` environment variable | Collection on top of which the command will be executed |
| upsert | `false` | If set to `true`, creates a new document if no documents match the filter |
### > examples

@@ -285,9 +252,2 @@ ```TypeScript

### > options
| Options | Default | Description |
|--------------|-------------------------------------------------------|---------------------------------------------------------|
| collection | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| database | Value specified in the `mongodb` environment variable | Collection on top of which the command will be executed |
### > examples

@@ -319,9 +279,2 @@ ```TypeScript

### > options
| Options | Default | Description |
|--------------|-------------------------------------------------------|---------------------------------------------------------|
| collection | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| database | Value specified in the `mongodb` environment variable | Collection on top of which the command will be executed |
### > examples

@@ -335,2 +288,22 @@ ```TypeScript

### > available options
| Options | Default | Description |
|----------------------------|-------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| database | Value specified in the `mongodb` environment variable | Database on top of which the command will be executed |
| collection | Value specified in the `mongodb` environment variable | Collection on top of which the command will be executed |
| failSilently | `false` | Control if the command will fail or if the collection is not found |
| `createCollection` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/CreateCollectionOptions.html) |
| `dropCollection` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/DropCollectionOptions.html) |
| `insertOne` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/InsertOneOptions.html) |
| `insertMany` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/BulkWriteOptions.html) |
| `findOne` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/FindOptions.html) |
| `findMany` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/FindOptions.html) |
| `findOneAndUpdate` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/FindOneAndUpdateOptions.html) |
| `findOneAndDelete` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/FindOneAndDeleteOptions.html) |
| `updateOne` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/UpdateOptions.html) |
| `updateMany` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/UpdateOptions.html) |
| `deleteOne` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/DeleteOptions.html) |
| `deleteMany` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/DeleteOptions.html) |
| `aggregate` options | *N/A* | Refer to official [documentation](https://mongodb.github.io/node-mongodb-native/4.10/interfaces/AggregateOptions.html) |
# Reference

@@ -337,0 +310,0 @@ https://mongodb.github.io/node-mongodb-native/4.10/classes/Collection.html

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