lab.test('it returns the raw mongodb collection', () => { class DummyModel extends MongoModels {} DummyModel.collectionName = 'dummies'; const collection = DummyModel.collection(); lab.expect(collection).to.be.an.instanceof(Mongodb.Collection); });
(function () { var opMethod = ['insert', 'update', 'findAndModify', 'remove']; var colPrototype = Mongoat.Collection.prototype; colPrototype.init(); for (var i = 0; i < opMethod.length; ++i) { colPrototype[opMethod[i] + 'Method'] = colPrototype[opMethod[i]]; } })();
constructor (name, schema, db, opts) { opts = opts || {} this._db = db this._schema = schema this._name = name this._collName = opts.collName || inflected.pluralize(name).toLowerCase() this._opts = opts this._plugins = {} Query.bindQuery(this, mongodb.Collection) // alias this.create = this.insert this.index = this.createIndex _.defaults(this._plugins, this._db._plugins) }
const findStub = sinon.stub(mongodb.Collection.prototype, 'deleteMany').rejects(errorStub);
const findOneSpy = sinon.stub(mongodb.Collection.prototype, 'find'); const findStub = sinon.stub(mongodb.Collection.prototype, 'find').rejects(errorStub); const logErrorSpy = sinon.spy(Logger.prototype, 'error');
const updateOneSpy = sinon.spy(mongodb.Collection.prototype, 'insertOne'); const insertOneStub = sinon.stub(mongodb.Collection.prototype, 'insertOne').rejects(errorStub); const logErrorSpy = sinon.spy(Logger.prototype, 'error');
const findStub = sinon.stub(mongodb.Collection.prototype, 'find').rejects(errorStub);
const updateOneSpy = sinon.spy(mongodb.Collection.prototype, 'updateOne'); const updateOneSpy = sinon.spy(mongodb.Collection.prototype, 'updateOne'); const findStub = sinon.stub(mongodb.Collection.prototype, 'updateOne').rejects(errorStub);