Fixed test case to a real world scenario, and subsequently fixed type definition

This commit is contained in:
Roberts Slisans
2017-06-29 12:11:38 +03:00
parent 8d0889c41a
commit b41d94cdd2
2 changed files with 9 additions and 0 deletions
+6
View File
@@ -4,6 +4,12 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="mongoose" />
declare module 'mongoose-simple-random' {
import mongoose = require('mongoose');
var _: (schema: mongoose.Schema) => void;
export = _;
}
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);