This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-blog-newsletter/cronjob/node_modules/mongodb/lib/operations/collections.js
2024-05-26 22:54:55 +02:00

29 lines
No EOL
1.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollectionsOperation = void 0;
const collection_1 = require("../collection");
const operation_1 = require("./operation");
/** @internal */
class CollectionsOperation extends operation_1.AbstractOperation {
constructor(db, options) {
super(options);
this.options = options;
this.db = db;
}
execute(server, session, callback) {
const db = this.db;
// Let's get the collection names
db.listCollections({}, { ...this.options, nameOnly: true, readPreference: this.readPreference, session }).toArray((err, documents) => {
if (err || !documents)
return callback(err);
// Filter collections removing any illegal ones
documents = documents.filter(doc => doc.name.indexOf('$') === -1);
// Return the collection objects
callback(undefined, documents.map(d => {
return new collection_1.Collection(db, d.name, db.s.options);
}));
});
}
}
exports.CollectionsOperation = CollectionsOperation;
//# sourceMappingURL=collections.js.map