You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Document,Schema,model}from'mongoose';interfaceUserextendsDocument{_id: string;roles: Map<string,string[]>;}constschema=newSchema<User>({_id: {required: true,type: String},roles: {of: Map,type: [String]},});constUsers=model<User>('users',schema);constlevel=5;Users.findByIdAndUpdate('abc',{$set: {/* Type '{ [x: string]: string[]; }' is missing the following properties from type 'Map<string, string[]>': clear, delete, forEach, get, and 8 more. */roles: {[level.toString()]: ['abc','abc2']},},});
Am I doing something wrong when updating a single entry on a map? If so, please let me know how to do it properly
And on a side note, I would rather have it be Map<number, string[]>, if possible, but if it isn't then that's completely fine.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Consider this example:
Am I doing something wrong when updating a single entry on a map? If so, please let me know how to do it properly
And on a side note, I would rather have it be
Map<number, string[]>
, if possible, but if it isn't then that's completely fine.Versions:
Beta Was this translation helpful? Give feedback.
All reactions