Created type definition & wrote test case

This commit is contained in:
Roberts Slisans
2017-06-22 19:53:01 +03:00
parent ee9e7794e9
commit 114d42bcdb
4 changed files with 50 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for mongoose-simple-random 0.4
// 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" />
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)
: void;
}
}
@@ -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!"); }
});
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }