Closed SimonSimCity closed 4 years ago
This change breaks an existing upsert, that works in 3.0.4:
Tags.upsert(
{
"color": "orange",
"label": "Today",
"team": {
"id": "jPrbLLC8mMQcMe6ZC",
"slug": "myteam"
}
},
{
"$set": {
"lastUsedAt": new Date
}
}
)
In 3.0.5 gives the following error: Error: Team is required in tags update
I20200107-20:20:52.143(1)? invalidKeys:
I20200107-20:20:52.144(1)? [ { name: 'team', type: 'required', value: undefined },
I20200107-20:20:52.144(1)? { name: 'team.id', type: 'required', value: undefined },
I20200107-20:20:52.144(1)? { name: 'team.slug', type: 'required', value: undefined } ],
This is the schema:
Tags.attachSchema(new SimpleSchema({
team: {
type: new SimpleSchema({
id: {
type: String
},
slug: {
type: String
}
})
},
color: {
type: String
},
label: {
type: String
},
lastUsedAt: {
type: Date
}
}))
@Rijk It's best to report this as a new issue ...
https://github.com/Meteor-Community-Packages/meteor-collection2/commit/379c810a54d99c729b7a94c1c5228d9b19c83787
https://docs.mongodb.com/manual/reference/method/db.collection.update/#insert-a-new-document-if-no-match-exists-upsert The second tab ("Upsert with Operator Expressions") looks good until you encounter the fact, that you also have operators which will create the value on the document.
Of the operators I've tested its only
$in
(only having one element in the list) and$eq
which should be taken as term. Children of a$and
should be parsed as well.