diff --git a/types/mongoose-simple-random/index.d.ts b/types/mongoose-simple-random/index.d.ts new file mode 100644 index 0000000000..deed6a036f --- /dev/null +++ b/types/mongoose-simple-random/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for mongoose-simple-random 0.4 +// Project: https://github.com/larryprice/mongoose-simple-random +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +declare module "mongoose" { + interface Model extends NodeJS.EventEmitter, ModelProperties { + findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void) + : void; + } +} diff --git a/types/mongoose-simple-random/mongoose-simple-random-tests.ts b/types/mongoose-simple-random/mongoose-simple-random-tests.ts new file mode 100644 index 0000000000..2aa9e18296 --- /dev/null +++ b/types/mongoose-simple-random/mongoose-simple-random-tests.ts @@ -0,0 +1,15 @@ +import * as mongoose from 'mongoose'; + +// test compatibility with other libraries - from @types/mongoose +import * as _ from 'lodash'; +import * as fs from "fs"; + +mongoose.Model.findRandom({ + username: { $ne: "DummyUser" }, + rating: { + $gt: 1, + $lt: 11, + }, +}, {}, { limit: 1 }, (error, data) => { + if (error) { console.error("Error!"); } else { console.log("Success!"); } +}); diff --git a/types/mongoose-simple-random/tsconfig.json b/types/mongoose-simple-random/tsconfig.json new file mode 100644 index 0000000000..28627f97dd --- /dev/null +++ b/types/mongoose-simple-random/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mongoose-simple-random-tests.ts" + ] +} diff --git a/types/mongoose-simple-random/tslint.json b/types/mongoose-simple-random/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mongoose-simple-random/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }