Reputation: 6019
A Meteor
server code tries to insert an object into a Mongo collection. The value of one of the property is a string which contains a dot i.e. ".".
Meteor terminal
is complaining :-
Error: key Food 1.1 and drinks must not contain '.'
What does this mean and how to fix it?
let obj = {
food: group,
rest: rule,
item: item[0],
key: i
};
FoodCol.insert(obj);
edit
The suggested answer by Kishor for replacing the "." with "\uff0E" will produce a space after the dot which is not what a user expects.
Upvotes: 1
Views: 3348
Reputation: 444
We solved this issue by encoding (Base64) the key before insertion and decode after taking out from the db. Since we consume the document as it is and query fields are different and their keys are not encoded.
But if u want to make query using this key or the key should be readable to the user, this solution will be not be suitable.
Upvotes: 1
Reputation: 2677
From this link, How to use dot in field name?
You can replace dot symbols of your field name to Unicode equivalent "\uff0E":
Update: As Fred suggested, please use "\u002E" for "."
Upvotes: 2