From e731bb5edf8d72fccfbf215f5360cc3c643d5170 Mon Sep 17 00:00:00 2001 From: arichter83 Date: Wed, 6 Feb 2019 00:45:54 +0100 Subject: [PATCH 1/2] Fix $addToSet --- types/meteor/mongo.d.ts | 2 +- types/meteor/test/meteor-tests.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) 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 */ From fe4db4f74ef8bc5181048bae50734cdd40e11310 Mon Sep 17 00:00:00 2001 From: arichter83 Date: Wed, 6 Feb 2019 09:13:59 +0100 Subject: [PATCH 2/2] Added Meteor.absoluteUrl.defaultOptions --- types/meteor/meteor.d.ts | 15 ++++++++++----- types/meteor/test/meteor-tests.ts | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/types/meteor/meteor.d.ts b/types/meteor/meteor.d.ts index ca08c31c98..e1a51fe48e 100644 --- a/types/meteor/meteor.d.ts +++ b/types/meteor/meteor.d.ts @@ -63,11 +63,16 @@ declare module "meteor/meteor" { /** Method **/ /** Url **/ - function absoluteUrl(path?: string, options?: { - secure?: boolean; - replaceLocalhost?: boolean; - rootUrl?: string; - }): string; + var absoluteUrl: { + (path?: string, options?: absoluteUrlOptions): string; + defaultOptions: absoluteUrlOptions; + } + + interface absoluteUrlOptions { + secure?: boolean; + replaceLocalhost?: boolean; + rootUrl?: string; + } /** Url **/ /** Timeout **/ diff --git a/types/meteor/test/meteor-tests.ts b/types/meteor/test/meteor-tests.ts index 8a9a32ddde..db6815caf2 100644 --- a/types/meteor/test/meteor-tests.ts +++ b/types/meteor/test/meteor-tests.ts @@ -812,3 +812,10 @@ const collectionWithoutConnection = new Mongo.Collection("monkey", { }); } // End of namespace + +// absoluteUrl +Meteor.absoluteUrl('/sub', {rootUrl: 'http://wonderful.com'}); +Meteor.absoluteUrl.defaultOptions = { + rootUrl: 'http://123.com', + secure: false +};