Merge pull request #32814 from understandr/Meteor-PR

[Meteor] fix Mongo $addToSet and add Meteor.absoluteUrl.defaultOptions
This commit is contained in:
Armando Aguirre
2019-02-06 13:00:57 -08:00
committed by GitHub
3 changed files with 36 additions and 7 deletions
+10 -5
View File
@@ -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 **/
+1 -1
View File
@@ -96,7 +96,7 @@ declare module "meteor/mongo" {
{ $each?: T[P], $position?: number, $slice?: number, $sort?: 1 | -1 | Dictionary<number> }
}
type ArraysOrEach<T> = {
[P in keyof T]?: OnlyArrays<T[P]> | { $each: T[P] }
[P in keyof T]?: OnlyElementsOfArrays<T[P]> | { $each: T[P] }
}
type CurrentDateModifier = { $type: "timestamp" | "date" } | true
type Modifier<T> = T | {
+25 -1
View File
@@ -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<Players> = 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
*/
@@ -795,3 +812,10 @@ const collectionWithoutConnection = new Mongo.Collection<MonkeyDAO>("monkey", {
});
} // End of namespace
// absoluteUrl
Meteor.absoluteUrl('/sub', {rootUrl: 'http://wonderful.com'});
Meteor.absoluteUrl.defaultOptions = {
rootUrl: 'http://123.com',
secure: false
};