From b41d94cdd229b584982ced69ccba99cc28631a36 Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Thu, 29 Jun 2017 12:11:38 +0300 Subject: [PATCH] Fixed test case to a real world scenario, and subsequently fixed type definition --- types/mongoose-simple-random/index.d.ts | 6 ++++++ .../mongoose-simple-random/mongoose-simple-random-tests.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/types/mongoose-simple-random/index.d.ts b/types/mongoose-simple-random/index.d.ts index deed6a036f..a57f366df2 100644 --- a/types/mongoose-simple-random/index.d.ts +++ b/types/mongoose-simple-random/index.d.ts @@ -4,6 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +declare module 'mongoose-simple-random' { + import mongoose = require('mongoose'); + var _: (schema: mongoose.Schema) => void; + export = _; +} + declare module "mongoose" { interface Model extends NodeJS.EventEmitter, ModelProperties { findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void) diff --git a/types/mongoose-simple-random/mongoose-simple-random-tests.ts b/types/mongoose-simple-random/mongoose-simple-random-tests.ts index 2aa9e18296..f5b26dbebb 100644 --- a/types/mongoose-simple-random/mongoose-simple-random-tests.ts +++ b/types/mongoose-simple-random/mongoose-simple-random-tests.ts @@ -1,4 +1,5 @@ import * as mongoose from 'mongoose'; +import * as mongoose_simple_random from "mongoose-simple-random"; // test compatibility with other libraries - from @types/mongoose import * as _ from 'lodash'; @@ -13,3 +14,5 @@ mongoose.Model.findRandom({ }, {}, { limit: 1 }, (error, data) => { if (error) { console.error("Error!"); } else { console.log("Success!"); } }); + +mongoose.plugin(mongoose_simple_random);