mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-26 20:10:03 +00:00
Merge pull request #17604 from rsxdalv/master
mongoose-simple-random fix for importing package with ES2015
This commit is contained in:
12
types/mongoose-simple-random/index.d.ts
vendored
12
types/mongoose-simple-random/index.d.ts
vendored
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user