diff --git a/types/meteor/mongo.d.ts b/types/meteor/mongo.d.ts index 84b2d53528..079bf6272d 100644 --- a/types/meteor/mongo.d.ts +++ b/types/meteor/mongo.d.ts @@ -96,7 +96,7 @@ declare module "meteor/mongo" { { $each?: T[P], $position?: number, $slice?: number, $sort?: 1 | -1 | Dictionary } } type ArraysOrEach = { - [P in keyof T]?: OnlyArrays | { $each: T[P] } + [P in keyof T]?: OnlyElementsOfArrays | { $each: T[P] } } type CurrentDateModifier = { $type: "timestamp" | "date" } | true type Modifier = T | { diff --git a/types/meteor/test/meteor-tests.ts b/types/meteor/test/meteor-tests.ts index 8e14f39fb1..8a9a32ddde 100644 --- a/types/meteor/test/meteor-tests.ts +++ b/types/meteor/test/meteor-tests.ts @@ -246,7 +246,13 @@ Items.insert({ list: groceriesId, name: "Persimmons" }); /** * From Collections, collection.update section */ -var Players = new Mongo.Collection('Players'); + +interface Players { + score: number + badges: string[] +} + +var Players: Mongo.Collection = new Mongo.Collection('Players'); Template['adminDashboard'].events({ 'click .givePoints': function () { @@ -265,6 +271,17 @@ Meteor.methods({ } }); +/** + * Also from Collections, collection.update section + */ +Meteor.methods({ + declareWinners: function () { + Players.update({ score: { $gt: 10 } }, + { $addToSet: { badges: {$each: ["Winner", "Super"]} } }, + { multi: true }); + } +}); + /** * From Collections, collection.remove section */