Merge pull request #11361 from simonxca/patch-mongoose

Add missing type parameter to mongoose.types.array
This commit is contained in:
Horiuchi_H
2016-09-21 13:08:49 +09:00
committed by GitHub
2 changed files with 20 additions and 2 deletions
+19 -1
View File
@@ -1,6 +1,10 @@
/// <reference path="mongoose.d.ts" />
/// <reference path="../lodash/lodash.d.ts"/>
import * as mongoose from 'mongoose';
// test compatibility with other libraries
import * as _ from 'lodash';
var fs = require('fs');
// dummy variables
@@ -458,6 +462,20 @@ mongooseArray.unshift(2, 4, 'hi').toFixed();
/* inherited properties */
mongooseArray.concat();
mongooseArray.length;
/* practical examples */
interface MySubEntity extends mongoose.Types.Subdocument {
property1: string;
property2: string;
}
interface MyEntity extends mongoose.Document {
sub: mongoose.Types.Array<MySubEntity>
}
var myEntity: MyEntity;
var subDocArray = _.filter(myEntity.sub, function (sd) {
sd.property1;
sd.property2.toLowerCase();
});
/*
* section types/documentarray.js
@@ -1397,4 +1415,4 @@ const extended: mongoose.Model<extended> = base.discriminator<extended>('extende
const x = new extended({
username: 'hi', // required in baseSchema
email: 'beddiw', // required in extededSchema
})
});
+1 -1
View File
@@ -927,7 +927,7 @@ declare module "mongoose" {
* section types/array.js
* http://mongoosejs.com/docs/api.html#types-array-js
*/
class Array<T> extends global.Array {
class Array<T> extends global.Array<T> {
/**
* Atomically shifts the array at most one time per document save().
* Calling this mulitple times on an array before saving sends the same command as