Fix $addToSet

This commit is contained in:
arichter83
2019-02-06 00:45:54 +01:00
parent 2ac00dd113
commit e731bb5edf
2 changed files with 19 additions and 2 deletions
+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 | {
+18 -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
*/