Merge pull request #17604 from rsxdalv/master

mongoose-simple-random fix for importing package with ES2015
This commit is contained in:
Paul van Brenk
2017-06-29 12:45:24 -07:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -2,9 +2,17 @@
// Project: https://github.com/larryprice/mongoose-simple-random
// Definitions by: My Self <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="mongoose" />
// tslint:disable-next-line no-single-declare-module
declare module 'mongoose-simple-random' {
import mongoose = require('mongoose');
// Dummy function allows to avoid hard to kill or fix tslint warning
// (exporting pluginFunc will make this a non-importable module)
function pluginFunc(schema: mongoose.Schema): void;
// Let allows typescript to still use ES2015 style imports
let plugin: typeof pluginFunc;
export = plugin;
}
declare module "mongoose" {
interface Model<T extends Document> extends NodeJS.EventEmitter, ModelProperties {
findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void)

View File

@@ -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);